Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

Commit 3f6e8e03 authored by Randy Sommerfeld's avatar Randy Sommerfeld

Deprecate time() in favour of new Date()

parent 55734bd6
......@@ -66,7 +66,7 @@ const MAX_USERHOST = 6; /* Maximum arguments to USERHOST command */
const MAX_REALNAME = 50; /* Maximum length of users real name field */
const SERVER_UPTIME = system.timer;
const SERVER_UPTIME_STRF = strftime("%a %b %d %Y at %H:%M:%S %Z",time());
const SERVER_UPTIME_STRF = strftime("%a %b %d %Y at %H:%M:%S %Z",new Date());
/*** Global Objects, Arrays and Variables - Always in Mixed_Case ***/
......@@ -94,7 +94,7 @@ var Profile = {}; /* CPU profiling */
/* Global Variables */
var Default_Port = 6667;
var Time_Config_Read; /* Stores time() of when the config was last read */
var Time_Config_Read; /* Stores unix epoch of when the config was last read */
/* Will this server try to enforce good network behaviour? */
/* Setting to "true" results in bouncing bad modes, KILLing bogus NICKs, etc. */
......
......@@ -64,7 +64,7 @@ function Channel(nam) {
this.modelist[CHANMODE_BAN] = [];
this.bantime = {};
this.bancreator = {};
this.created = time();
this.created = Epoch();
/* Functions */
this.chanmode = Channel_chanmode;
this.isbanned = Channel_isbanned;
......@@ -447,7 +447,7 @@ function IRCClient_set_chanmode(chan,modeline,bounce_modes) {
cmode.addmodes += "b";
cmode.addmodeargs += " " + set_ban;
var banid = chan.modelist[CHANMODE_BAN].push(set_ban) - 1;
chan.bantime[banid] = time();
chan.bantime[banid] = Epoch();
chan.bancreator[banid] = this.nuh;
}
}
......
......@@ -195,7 +195,7 @@ function Read_Config_File() {
log(LOG_NOTICE, "Couldn't open configuration file! Proceeding with defaults.");
}
Time_Config_Read = time();
Time_Config_Read = Epoch();
Scan_For_Banned_Clients();
YLines[0] = new YLine(120,600,1,5050000); /* Default IRC class */
......
......@@ -757,7 +757,7 @@ function IRCClient_numeric382(str) {
function IRCClient_numeric391() {
this.numeric(391, ServerName + " :"
+ strftime("%A %B %d %Y -- %H:%M %z",time()));
+ strftime("%A %B %d %Y -- %H:%M %z",new Date()));
}
function IRCClient_numeric401(str) {
......@@ -1118,7 +1118,7 @@ function IRCClient_do_whois(wi) {
this.numeric(317, format(
"%s %s %s :seconds idle, signon time",
wi.nick,
time() - wi.talkidle,
Epoch() - wi.talkidle,
wi.connecttime
));
}
......@@ -2021,9 +2021,9 @@ function IRCClient_do_complex_who(cmd) {
continue;
else if ((who.del_flags&WHO_MEMBER_CHANNEL) && flag_M)
continue;
if ((who.add_flags&WHO_TIME) && ((time() - wc.connecttime) < who.Time))
if ((who.add_flags&WHO_TIME) && ((Epoch() - wc.connecttime) < who.Time))
continue;
else if ((who.del_flags&WHO_TIME) && ((time() - wc.connecttime) > who.Time))
else if ((who.del_flags&WHO_TIME) && ((Epoch() - wc.connecttime) > who.Time))
continue;
if ((who.add_flags&WHO_CLASS) && (wc.ircclass != who.Class))
continue;
......@@ -2291,10 +2291,10 @@ function IRCClient_do_complex_list(cmd) {
wildmatch(i,list.Mask.toUpperCase()))
continue;
if ((list.add_flags&LIST_CREATED) &&
(Channels[i].created < (time() - list.Created)))
(Channels[i].created < (Epoch() - list.Created)))
continue;
else if ((list.del_flags&LIST_CREATED) &&
(Channels[i].created > (time() - list.Created)))
(Channels[i].created > (Epoch() - list.Created)))
continue;
if ((list.add_flags&LIST_TOPIC) &&
(!wildmatch(Channels[i].topic,list.Topic)))
......@@ -2309,10 +2309,10 @@ function IRCClient_do_complex_list(cmd) {
(true_array_len(Channels[i].users) >= list.People) )
continue;
if ((list.add_flags&LIST_TOPICAGE) && list.TopicTime &&
(Channels[i].topictime > (time()-list.TopicTime)))
(Channels[i].topictime > (Epoch()-list.TopicTime)))
continue;
else if((list.del_flags&LIST_TOPICAGE)&&list.TopicTime&&
(Channels[i].topictime < (time()-list.TopicTime)))
(Channels[i].topictime < (Epoch()-list.TopicTime)))
continue;
if (list.add_flags&LIST_MODES) { /* there's no -m */
var sic = false;
......@@ -2470,21 +2470,21 @@ function Channel_match_list_mask(mask) {
return 0;
} else if (mask[0].toUpperCase() == "C") { /* created X mins ago? */
if ( (mask[1] == ">")
&& (this.created < (time() - (parseInt(mask.slice(2)) * 60)))
&& (this.created < (Epoch() - (parseInt(mask.slice(2)) * 60)))
) {
return 0;
} else if ( (mask[1] == "<")
&& (this.created > (time() - (parseInt(mask.slice(2)) * 60)))
&& (this.created > (Epoch() - (parseInt(mask.slice(2)) * 60)))
) {
return 0;
}
} else if (mask[0].toUpperCase() == "T") { /* topics older than X mins? */
if ( (mask[1] == ">")
&& (this.topictime < (time() - (parseInt(mask.slice(2)) * 60)) )
&& (this.topictime < (Epoch() - (parseInt(mask.slice(2)) * 60)) )
) {
return 0;
} else if ( (mask[1] == "<")
&& (this.topictime > (time() - (parseInt(mask.slice(2)) * 60)))
&& (this.topictime > (Epoch() - (parseInt(mask.slice(2)) * 60)))
) {
return 0;
}
......@@ -2821,6 +2821,10 @@ function Uptime_String() {
);
}
function Epoch() {
return parseInt(new Date().getTime()/1000);
}
/** Global object prototypes **/
function CLine(host,password,servername,port,ircclass) {
......
......@@ -529,7 +529,7 @@ function Server_Work(cmdline) {
}
/* Don't trust what a leaf tells us */
p[1] = 1;
p[2] = time();
p[2] = Epoch();
p[6] = this.nick;
} else { /* Hub (trusted) */
tmp = searchbyserver(p[6]);
......@@ -661,7 +661,7 @@ function Server_Work(cmdline) {
if (this.hub)
origin.created = parseInt(p[1]);
else
origin.created = time();
origin.created = Epoch();
origin.bcast_to_uchans_unique(format(
"NICK %s",
p[0]
......@@ -1107,7 +1107,7 @@ function Server_Work(cmdline) {
break;
if (p[3] == tmp.topic)
break;
tmp.topictime = this.hub ? p[2] : time();
tmp.topictime = this.hub ? p[2] : Epoch();
tmp.topic = p[3];
tmp.topicchangedby = p[1];
origin.bcast_to_channel(tmp, format(
......
......@@ -40,7 +40,7 @@ function Unregistered_Client(id,socket) {
}
this.hostname = this.ip;
this.pending_resolve = false;
this.dns_pending = time();
this.dns_pending = Epoch();
// Variables (consts, really) that point to various state information
this.socket = socket;
this.socket.irc = this;
......@@ -262,7 +262,7 @@ function Unregistered_Check_User_Registration() {
if (this.password.toUpperCase() == bbsuser.security.password) {
this.uprefix = parse_username(bbsuser.handle);
bbsuser.connection = "IRC";
bbsuser.logontime = time();
bbsuser.logontime = Epoch();
}
}
}
......@@ -343,7 +343,7 @@ function Unregistered_Welcome() {
new_user.uprefix = this.uprefix;
new_user.hostname = this.hostname;
new_user.realname = this.realname;
new_user.created = time();
new_user.created = Epoch();
new_user.ip = this.ip;
new_user.ircclass = my_iline.ircclass;
new_user.sendq = this.sendq;
......
......@@ -124,7 +124,7 @@ function IRC_User(id) {
this.uline = false; /* Are we services? */
this.away = "";
this.channels = {};
this.connecttime = time();
this.connecttime = Epoch();
this.created = 0;
this.flags = 0;
this.hops = 0;
......@@ -138,7 +138,7 @@ function IRC_User(id) {
this.realname = "";
this.servername = ServerName;
this.silence = [];
this.talkidle = time();
this.talkidle = Epoch();
this.uprefix = "";
this.id = id;
this.socket = "";
......@@ -304,7 +304,7 @@ function User_Work(cmdline) {
for (i in tmp) {
this.do_msg(tmp[i],"PRIVMSG",p[1]);
}
this.talkidle = time();
this.talkidle = Epoch();
break;
case "MODE":
if (!p[0])
......@@ -458,7 +458,7 @@ function User_Work(cmdline) {
if (j == tmp.topic)
break;
tmp.topic = j;
tmp.topictime = time();
tmp.topictime = Epoch();
tmp.topicchangedby = this.nick;
this.bcast_to_channel(
tmp,
......@@ -994,7 +994,7 @@ function User_Work(cmdline) {
this.bcast_to_uchans_unique("NICK " + p[0]);
this.originatorout("NICK " + p[0],this);
if (p[0].toUpperCase() != this.nick.toUpperCase()) {
this.created = time();
this.created = Epoch();
push_nickbuf(this.nick,p[0]);
Users[p[0].toUpperCase()] = this;
delete Users[this.nick.toUpperCase()];
......
......@@ -271,8 +271,8 @@ function IRC_quit(server,reason) {
server.send("QUIT :" + reason + "\r\n");
/* wait up to 5 seconds for server to disconnect */
var start=time();
while(server.is_connected && time()-start<5) {
var start = new Date().getTime();
while(server.is_connected && new Date().getTime() - start < 5000) {
if (server.poll(0.5))
server.recvline();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment