📄 main.asc
字号:
//##########################################\\
//AVChat 1.3b main.asc FMS server side file##\\
//http://www.avchat.net#####################\\
//Compatible with both FCS 1.5 and FMS 2.0##\\
//application.deleteemptyrooms
//Change this variable to false if you want to
//disable the auto deletion of rooms when the
//last user exits them (this affects only rooms
//created by the users using the AVChat interface,
//this does not affect the Lobby)
application.deleteemptyrooms = true;
//application.oneuserperip
//Change this variable to true if you want to
//allow only 1 user from 1 ip at a time
application.oneuserperip = false;
//##########################################\\
//Do not modify anything under this line####\\
var aIps = [];
pingClient = function () {
trace('pingClientCalled,'+application.clients.length+' clients are reported to be connected!');
for (var i = 0; i<application.clients.length; i++) {
var stillThere = application.clients[i].ping();
if (stillThere == false) {
trace('found a Ghost');
application.disconnect(application.clients[i]);
}
}
};
application.onAppStart = function() {
trace('onAppStart');
nGhosts = setInterval(pingClient, 10000);
//Initializing the rooms list shared object
application.rooms_list = SharedObject.get("rooms_list", false);
application.r1_users = SharedObject.get("r1_users", false);
//banned users
application.ip_so = SharedObject.get("ip_so", false);
var banneduser = new Object();
banneduser.ip = "1.1.1.1";
today_date = new Date();
banneduser.date = today_date.getTime()/1000;
banneduser.duration = 742;
application.ip_so.setProperty(banneduser.ip, banneduser);
/*
var banneduser = new Object();
banneduser.ip = "1.1.1.1";
today_date = new Date();
banneduser.date = today_date.getTime()/1000;
banneduser.duration = 742;
application.ip_so.setProperty(banneduser.ip,banneduser);
*/
//we initialize the id numbers for roms,users and admin connections
application.adminId = 1;
application.roomId = 1;
application.usersId = 1;
application.history = "Application started\r\n";
//Initializing the Lobby room
var roomObj = new Object();
roomObj.name = "The Lobby";
roomObj.description = "No nudity or explicit language";
roomObj.pass = "";
roomObj.users = 0;
roomObj.persistent = true;
roomObj.id = "r"+application.roomId++;
//Adding the Lobby Room to the rooms shared object
application.rooms_list.setProperty(roomObj.id, roomObj);
now_date = new Date();
r1_log = '('+now_date+')Log initialized. Application started.';
//Initializing the log
now_date = new Date();
application.log = "<font color='#990000'>("+now_date+")Application Started, Lobby room created</font>";
};
application.onConnect = function(newClient, name, cam, mic, genre, usertype, hidden) {
trace('onConnect');
var banned = false;
//we assume that it is not
var names = application.ip_so.getPropertyNames();
trace(names);
for (x in names) {
var obj = application.ip_so.getProperty(names[x]);
if (obj != null) {
for (j in obj) {
trace(j+':'+obj[j]);
}
today_date = new Date();
now_time = today_date.getTime()/1000;
if (obj['ip'] == newClient.ip && obj['date']+obj['duration']>now_time) {
rmtime = Math.round((obj['date']+obj['duration']-now_time)/60);
var err = new Object();
err.message = "You have been banned for "+obj['duration']/3600+" hour(s). You still have to wait "+rmtime+" minutes of penalty.";
application.rejectConnection(newClient, err);
banned = true;
}
}
}
//we check to see if we already have a user from that IP
var bIpin = false;
if (application.oneuserperip == true) {
for (x in aIps) {
trace(x+':'+aIps[x]);
if (aIps[x] == ip) {
var err = new Object();
err.message = "There already is someone connected from this IP: "+ip+'.';
application.rejectConnection(newClient, err);
bIpin = true;
}
}
}
//if the ip is not banned
if (banned == false && bIpin == false) {
application.acceptConnection(newClient);
if (usertype == 'admin') {
newClient.id = application.usersId++;
application.adminId++;
} else {
newClient.id = application.usersId++;
aIps[newClient.id] = newClient.ip;
}
newClient.call("recieveid", null, newClient.id);
trace(name+"'s id is:"+newClient.id);
newClient.room = "r1";
newClient.hidden = hidden;
newClient.name = name;
var PeopleObj = new Object();
PeopleObj.name = name;
PeopleObj.type = usertype;
PeopleObj.cam = cam;
PeopleObj.mic = mic;
PeopleObj.ip = newClient.ip;
PeopleObj.genre = genre;
PeopleObj.id = newClient.id;
if (hidden == false) {
application.r1_users.setProperty(newClient.id, PeopleObj);
//we increase the number of users
var roomObj = application.rooms_list.getProperty("r1");
roomObj.users++;
application.rooms_list.setProperty("r1", roomObj);
application.r1_users.send("joinMsg", "joined", newClient.name);
//setting the log
now_date = new Date();
r1_log += '<br>('+now_date+')'+newClient.name+' joined the chat.';
}
newClient.getLog = function(roomid) {
newClient.call("recieveLog", null, eval(roomid+'_log'));
};
newClient.createRoom = function(name, description, password) {
var roomObj = new Object();
roomObj.name = name;
roomObj.description = description;
roomObj.pass = password;
roomObj.users = 0;
roomObj.persistent = false;
roomObj.id = "r"+application.roomId++;
application.rooms_list.setProperty(roomObj.id, roomObj);
//application.r1_users = SharedObject.get("r1_users", false);
eval('application.'+roomObj.id+'_users = SharedObject.get("'+roomObj.id+'_users", false);');
//setting the log
now_date = new Date();
r1_log += "<br>("+now_date+')Room:'+roomObj.name+" created.";
eval(roomObj.id+'_log="( '+now_date+' )Room created, log started."');
trace(eval(roomObj.id+'_log'));
};
newClient.hideCamera = function(room, id) {
eval("var personObj = application."+room+"_users.getProperty(id)");
personObj.cam = 0;
eval("application."+room+"_users.setProperty(id,personObj)");
};
newClient.showCamera = function(room, id) {
eval("var personObj = application."+room+"_users.getProperty(id)");
personObj.cam = 1;
eval("application."+room+"_users.setProperty(id,personObj)");
};
newClient.deleteRoom = function(id) {
application.rooms_list.setProperty(id, null);
eval('application.'+id+'_users.clear()');
};
newClient.joinRoom = function(from, to, id) {
if (hidden == false) {
//solve problems from where we leave
var roomObj = application.rooms_list.getProperty(from);
roomObj.users--;
if (roomObj.users<0) {
roomObj.users = 0;
}
application.rooms_list.setProperty(from, roomObj);
//setting the log
now_date = new Date();
eval(from+'_log+="<br>('+now_date+')'+newClient.name+' left the room"');
eval("var personObj = application."+from+"_users.getProperty(id)");
eval("application."+from+"_users.setProperty(id, null)");
eval("application."+from+"_users.send('joinMsg','left',newClient.name)");
//solve problems where we go
var roomObj = application.rooms_list.getProperty(to);
roomObj.users++;
application.rooms_list.setProperty(to, roomObj);
eval("application."+to+"_users.setProperty(id,personObj)");
eval("application."+to+"_users.send('setLog',"+to+"_log)");
eval("application."+to+"_users.send('joinMsg','joined',newClient.name)");
//we remove the room if there are no more users inside
var roomObj = application.rooms_list.getProperty(from);
if (roomObj.users<=0 && roomObj.persistent == false && application.deleteemptyrooms == true) {
application.rooms_list.setProperty(from, null);
eval('application.'+from+'_users.clear()');
}
newClient.room = to;
//setting the log
now_date = new Date();
eval(to+'_log+="<br>('+now_date+')'+newClient.name+' joined the chat"');
}
};
//function that handles transmission of private and public messages
newClient.userMsg = function(room, message, color, bold, italic, type, fromid, nick, destination, dstnm) {
trace("dstnm:"+dstnm);
if (type == "std_msg") {
//trace('application.'+room+'_users.send("msgFromUsers",message,color,bold,italic,fromid,nick)');
eval('application.'+room+'_users.send("msgFromUsers",message,color,bold,italic,fromid,nick)');
//setting the log
now_date = new Date();
//eval(room+'_log+="<br>('+now_date+')'+nick+':'+message+'."')
} else if (type == "pvt_msg") {
eval('application.'+room+'_users.send("msgFromUser",message,color,bold,italic,fromid,nick,destination)');
//setting the log
now_date = new Date();
//eval(room+'_log+="<br>('+now_date+')PM from '+nick+' to '+destination+':'+message+'."')
}
};
newClient.kickuser = function(id, roomid) {
trace("KICK function called for:"+id+" in "+roomid);
for (i=0; i<application.clients.length; i++) {
trace(application.clients[i]);
if (application.clients[i].id == id && application.clients[i].type != 'admin') {
trace("kick person found");
thename = application.clients[i].name;
application.disconnect(application.clients[i]);
eval('application.'+roomid+'_users.send("joinMsg","kicked",thename)');
//setting the log
now_date = new Date();
eval(roomid+'_log+="<br>('+now_date+')'+thename+' was kicked"');
}
}
};
newClient.banuser = function(id, ip, duration, room) {
trace("BAN function called on:"+id+"in "+room+" with ip:"+ip+", for:"+duration);
var banneduser = new Object();
banneduser['ip'] = ip;
today_date = new Date();
banneduser['date'] = today_date.getTime()/1000;
banneduser['duration'] = duration;
application.ip_so.setProperty(banneduser['ip'], banneduser);
//last we kick the person
for (i=0; i<application.clients.length; i++) {
if (application.clients[i].id == id) {
trace("bann person found");
thename = application.clients[i].name;
application.disconnect(application.clients[i]);
eval('application.'+room+'_users.send("joinMsg","banned",thename)');
}
}
};
}
};
application.onDisconnect = function(client) {
trace('onDisconnect');
trace('User is leaving from:'+client.room)
//we delete the user object (the users list will be updated)
if (client.hidden == false) {
eval("application."+client.room+"_users.send('joinMsg','disconected',client.name)");
//we update the rooms objects (the rooms list wil be updated)
var roomObj = application.rooms_list.getProperty(client.room);
roomObj.users--;
if (roomObj.users<0) {
roomObj.users = 0;
}
application.rooms_list.setProperty(client.room, roomObj);
//we remove the room if there are no more users inside
if (roomObj.users<=0 && roomObj.persistent == false && application.deleteemptyrooms == true) {
application.rooms_list.setProperty(client.room, null);
eval('application.'+client.room+'_users.clear()');
}
}
eval("application."+client.room+"_users.setProperty(client.id, null)");
aIps[client.id] = null;
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -