mirror of
https://github.com/fulpstation/fulpstation.git
synced 2025-12-09 16:09:15 +00:00
Unifed SQL message system (#23327)
* unifed sql message system to supersede notes, watchlist and memos and adds messages * a neserseree change
This commit is contained in:
@@ -8,6 +8,31 @@ Remember to add a prefix to the table name if you use them
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
25 January 2017, by Jordie0608
|
||||
|
||||
Created table 'messages' to supersede the 'notes', 'memos', and 'watchlist' tables; they must be collated into this new table
|
||||
|
||||
To create this new table run the following command:
|
||||
|
||||
CREATE TABLE `feedback`.`messages` (`id` INT(11) NOT NULL AUTO_INCREMENT , `type` VARCHAR(32) NOT NULL , `targetckey` VARCHAR(32) NOT NULL , `adminckey` VARCHAR(32) NOT NULL , `text` TEXT NOT NULL , `timestamp` DATETIME NOT NULL , `server` VARCHAR(32) NULL , `secret` TINYINT(1) NULL DEFAULT 1 , `lasteditor` VARCHAR(32) NULL , `edits` TEXT NULL , PRIMARY KEY (`id`) )
|
||||
|
||||
To copy the contents of the 'notes', 'memos', and 'watchlist' tables to this new table run the following commands:
|
||||
|
||||
INSERT INTO `feedback`.`messages`
|
||||
(`id`,`type`,`targetckey`,`adminckey`,`text`,`timestamp`,`server`,`secret`,`lasteditor`,`edits`) SELECT `id`, "note", `ckey`, `adminckey`, `notetext`, `timestamp`, `server`, `secret`, `last_editor`, `edits` FROM `feedback`.`notes`
|
||||
|
||||
INSERT INTO `feedback`.`messages`
|
||||
(`type`,`targetckey`,`adminckey`,`text`,`timestamp`,`lasteditor`,`edits`) SELECT "memo", `ckey`, `ckey`, `memotext`, `timestamp`, `last_editor`, `edits` FROM `feedback`.`memo`
|
||||
|
||||
INSERT INTO `feedback`.`messages`
|
||||
(`type`,`targetckey`,`adminckey`,`text`,`timestamp`,`lasteditor`,`edits`) SELECT "watchlist entry", `ckey`, `adminckey`, `reason`, `timestamp`, `last_editor`, `edits` FROM `feedback`.`watch`
|
||||
|
||||
It's not necessary to delete the 'notes', 'memos', and 'watchlist' tables but they will no longer be used.
|
||||
|
||||
Remember to add a prefix to the table names if you use them
|
||||
|
||||
----------------------------------------------------
|
||||
|
||||
1 September 2016, by Jordie0608
|
||||
|
||||
Modified table 'notes', adding column 'secret'.
|
||||
|
||||
@@ -314,61 +314,9 @@ CREATE TABLE `poll_vote` (
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Table structure for table `watch`
|
||||
-- Table structure for table `ipintel`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `watch`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `watch` (
|
||||
`ckey` varchar(32) NOT NULL,
|
||||
`reason` text NOT NULL,
|
||||
`timestamp` datetime NOT NULL,
|
||||
`adminckey` varchar(32) NOT NULL,
|
||||
`last_editor` varchar(32),
|
||||
`edits` text,
|
||||
PRIMARY KEY (`ckey`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Table structure for table `memo`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `memo`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `memo` (
|
||||
`ckey` varchar(32) NOT NULL,
|
||||
`memotext` text NOT NULL,
|
||||
`timestamp` datetime NOT NULL,
|
||||
`last_editor` varchar(32),
|
||||
`edits` text,
|
||||
PRIMARY KEY (`ckey`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Table structure for table `notes`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `notes`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `notes` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`ckey` varchar(32) NOT NULL,
|
||||
`notetext` text NOT NULL,
|
||||
`timestamp` datetime NOT NULL,
|
||||
`adminckey` varchar(32) NOT NULL,
|
||||
`last_editor` varchar(32),
|
||||
`edits` text,
|
||||
`server` varchar(50) NOT NULL,
|
||||
`secret` tinyint(1) NOT NULL DEFAULT '1',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
DROP TABLE IF EXISTS `ipintel`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
@@ -379,4 +327,25 @@ CREATE TABLE `ipintel` (
|
||||
PRIMARY KEY ( `ip` )
|
||||
) ENGINE = INNODB;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
-- Dump completed on 2013-03-24 18:02:35
|
||||
|
||||
--
|
||||
-- Table structure for table `messages`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `messages`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `messages` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT ,
|
||||
`type` varchar(32) NOT NULL ,
|
||||
`targetckey` varchar(32) NOT NULL ,
|
||||
`adminckey` varchar(32) NOT NULL ,
|
||||
`text` text NOT NULL ,
|
||||
`timestamp` datetime NOT NULL ,
|
||||
`server` varchar(32) NULL ,
|
||||
`secret` tinyint(1) NULL DEFAULT 1 ,
|
||||
`lasteditor` varchar(32) NULL ,
|
||||
`edits` text NULL ,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
@@ -308,61 +308,9 @@ CREATE TABLE `SS13_poll_vote` (
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Table structure for table `SS13_watch`
|
||||
-- Table structure for table `SS13_ipintel`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `SS13_watch`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `SS13_watch` (
|
||||
`ckey` varchar(32) NOT NULL,
|
||||
`reason` text NOT NULL,
|
||||
`timestamp` datetime NOT NULL,
|
||||
`adminckey` varchar(32) NOT NULL,
|
||||
`last_editor` varchar(32),
|
||||
`edits` text,
|
||||
PRIMARY KEY (`ckey`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Table structure for table `SS13_memo`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `SS13_memo`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `SS13_memo` (
|
||||
`ckey` varchar(32) NOT NULL,
|
||||
`memotext` text NOT NULL,
|
||||
`timestamp` datetime NOT NULL,
|
||||
`last_editor` varchar(32),
|
||||
`edits` text,
|
||||
PRIMARY KEY (`ckey`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Table structure for table `SS13_notes`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `SS13_notes`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `SS13_notes` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`ckey` varchar(32) NOT NULL,
|
||||
`notetext` text NOT NULL,
|
||||
`timestamp` datetime NOT NULL,
|
||||
`adminckey` varchar(32) NOT NULL,
|
||||
`last_editor` varchar(32),
|
||||
`edits` text,
|
||||
`server` varchar(50) NOT NULL,
|
||||
`secret` tinyint(1) NOT NULL DEFAULT '1',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
DROP TABLE IF EXISTS `SS13_ipintel`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
@@ -373,4 +321,25 @@ CREATE TABLE `SS13_ipintel` (
|
||||
PRIMARY KEY ( `ip` )
|
||||
) ENGINE = INNODB;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
-- Dump completed on 2013-03-24 18:02:35
|
||||
|
||||
--
|
||||
-- Table structure for table `SS13_messages`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `SS13_messages`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `SS13_messages` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT ,
|
||||
`type` varchar(32) NOT NULL ,
|
||||
`targetckey` varchar(32) NOT NULL ,
|
||||
`adminckey` varchar(32) NOT NULL ,
|
||||
`text` text NOT NULL ,
|
||||
`timestamp` datetime NOT NULL ,
|
||||
`server` varchar(32) NULL ,
|
||||
`secret` tinyint(1) NULL DEFAULT 1 ,
|
||||
`lasteditor` varchar(32) NULL ,
|
||||
`edits` text NULL ,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
@@ -28,7 +28,6 @@ var/datum/subsystem/minimap/SSminimap
|
||||
world << "<span class='boldannounce'>Minimap generation disabled. Loading from cache...</span>"
|
||||
var/fileloc = 0
|
||||
if(check_files(0)) //Let's first check if we have maps cached in the data folder. NOTE: This will override the backup files even if this map is older.
|
||||
world.log << "cache"
|
||||
if(hash != trim(file2text(hash_path())))
|
||||
world << "<span class='boldannounce'>Loaded cached minimap is outdated. There may be minor discrepancies in layout.</span>" //Disclaimer against players saying map is wrong.
|
||||
fileloc = 0
|
||||
|
||||
@@ -117,9 +117,9 @@ var/savefile/Banlist
|
||||
if (temp)
|
||||
Banlist["minutes"] << bantimestamp
|
||||
if(!temp)
|
||||
add_note(ckey, "Permanently banned - [reason]", null, bannedby, 0, null, 0)
|
||||
create_message("note", ckey, bannedby, "Permanently banned - [reason]", null, null, 0, 0)
|
||||
else
|
||||
add_note(ckey, "Banned for [minutes] minutes - [reason]", null, bannedby, 0, null, 0)
|
||||
create_message("note", ckey, bannedby, "Banned for [minutes] minutes - [reason]", null, null, 0, 0)
|
||||
return 1
|
||||
|
||||
/proc/RemoveBan(foldername)
|
||||
|
||||
@@ -61,14 +61,8 @@ var/global/BSACooldown = 0
|
||||
else
|
||||
body+= "<A href='?_src_=holder;jobban3=emote;jobban4=\ref[M]'>Emoteban</A> | "
|
||||
|
||||
body += "<A href='?_src_=holder;shownoteckey=[M.ckey]'>Notes</A> | "
|
||||
body += "<A href='?_src_=holder;showmessageckey=[M.ckey]'>Notes | Messages | Watchlist</A> | "
|
||||
if(M.client)
|
||||
if(M.client.check_watchlist(M.client.ckey))
|
||||
body += "<A href='?_src_=holder;watchremove=[M.ckey]'>Remove from Watchlist</A> | "
|
||||
body += "<A href='?_src_=holder;watchedit=[M.ckey]'>Edit Watchlist reason</A> "
|
||||
else
|
||||
body += "<A href='?_src_=holder;watchadd=\ref[M.ckey]'>Add to Watchlist</A> "
|
||||
|
||||
body += "| <A href='?_src_=holder;sendtoprison=\ref[M]'>Prison</A> | "
|
||||
body += "\ <A href='?_src_=holder;sendbacktolobby=\ref[M]'>Send back to Lobby</A> | "
|
||||
var/muted = M.client.prefs.muted
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
F << "<small>[time_stamp()] \ref[src] ([x],[y],[z])</small> || [src] [message]<br>"
|
||||
|
||||
//ADMINVERBS
|
||||
/client/proc/investigate_show( subject in list("hrefs","notes","watchlist","singulo","wires","telesci", "gravity", "records", "cargo", "supermatter", "atmos", "experimentor", "kudzu") )
|
||||
/client/proc/investigate_show( subject in list("hrefs","notes, memos, watchlist","singulo","wires","telesci", "gravity", "records", "cargo", "supermatter", "atmos", "experimentor", "kudzu") )
|
||||
set name = "Investigate"
|
||||
set category = "Admin"
|
||||
if(!holder)
|
||||
@@ -46,7 +46,5 @@
|
||||
else
|
||||
src << "<span class='danger'>No href logfile was found.</span>"
|
||||
return
|
||||
if("notes")
|
||||
show_note()
|
||||
if("watchlist")
|
||||
watchlist_show()
|
||||
if("notes, memos, watchlist")
|
||||
browse_messages()
|
||||
|
||||
@@ -1,131 +0,0 @@
|
||||
/client/proc/admin_memo()
|
||||
set name = "Memo"
|
||||
set category = "Server"
|
||||
if(!check_rights(0))
|
||||
return
|
||||
if(!dbcon.IsConnected())
|
||||
src << "<span class='danger'>Failed to establish database connection.</span>"
|
||||
return
|
||||
var/memotask = input(usr,"Choose task.","Memo") in list("Show","Write","Edit","Remove")
|
||||
if(!memotask)
|
||||
return
|
||||
admin_memo_output(memotask)
|
||||
|
||||
/client/proc/admin_memo_output(task)
|
||||
if(!task)
|
||||
return
|
||||
if(!dbcon.IsConnected())
|
||||
src << "<span class='danger'>Failed to establish database connection.</span>"
|
||||
return
|
||||
var/sql_ckey = sanitizeSQL(src.ckey)
|
||||
switch(task)
|
||||
if("Write")
|
||||
var/DBQuery/query_memocheck = dbcon.NewQuery("SELECT ckey FROM [format_table_name("memo")] WHERE ckey = '[sql_ckey]'")
|
||||
if(!query_memocheck.Execute())
|
||||
var/err = query_memocheck.ErrorMsg()
|
||||
log_game("SQL ERROR obtaining ckey from memo table. Error : \[[err]\]\n")
|
||||
return
|
||||
if(query_memocheck.NextRow())
|
||||
src << "You already have set a memo."
|
||||
return
|
||||
var/memotext = input(src,"Write your Memo","Memo") as message
|
||||
if(!memotext)
|
||||
return
|
||||
memotext = sanitizeSQL(memotext)
|
||||
var/timestamp = SQLtime()
|
||||
var/DBQuery/query_memoadd = dbcon.NewQuery("INSERT INTO [format_table_name("memo")] (ckey, memotext, timestamp) VALUES ('[sql_ckey]', '[memotext]', '[timestamp]')")
|
||||
if(!query_memoadd.Execute())
|
||||
var/err = query_memoadd.ErrorMsg()
|
||||
log_game("SQL ERROR adding new memo. Error : \[[err]\]\n")
|
||||
return
|
||||
log_admin("[key_name(src)] has set a memo: [memotext]")
|
||||
message_admins("[key_name_admin(src)] has set a memo:<br>[memotext]")
|
||||
if("Edit")
|
||||
var/DBQuery/query_memolist = dbcon.NewQuery("SELECT ckey FROM [format_table_name("memo")]")
|
||||
if(!query_memolist.Execute())
|
||||
var/err = query_memolist.ErrorMsg()
|
||||
log_game("SQL ERROR obtaining ckey from memo table. Error : \[[err]\]\n")
|
||||
return
|
||||
var/list/memolist = list()
|
||||
while(query_memolist.NextRow())
|
||||
var/lkey = query_memolist.item[1]
|
||||
memolist += "[lkey]"
|
||||
if(!memolist.len)
|
||||
src << "No memos found in database."
|
||||
return
|
||||
var/target_ckey = input(src, "Select whose memo to edit", "Select memo") as null|anything in memolist
|
||||
if(!target_ckey)
|
||||
return
|
||||
var/target_sql_ckey = sanitizeSQL(target_ckey)
|
||||
var/DBQuery/query_memofind = dbcon.NewQuery("SELECT memotext FROM [format_table_name("memo")] WHERE ckey = '[target_sql_ckey]'")
|
||||
if(!query_memofind.Execute())
|
||||
var/err = query_memofind.ErrorMsg()
|
||||
log_game("SQL ERROR obtaining memotext from memo table. Error : \[[err]\]\n")
|
||||
return
|
||||
if(query_memofind.NextRow())
|
||||
var/old_memo = query_memofind.item[1]
|
||||
var/new_memo = input("Input new memo", "New Memo", "[old_memo]", null) as message
|
||||
if(!new_memo)
|
||||
return
|
||||
new_memo = sanitizeSQL(new_memo)
|
||||
var/edit_text = "Edited by [sql_ckey] on [SQLtime()] from<br>[old_memo]<br>to<br>[new_memo]<hr>"
|
||||
edit_text = sanitizeSQL(edit_text)
|
||||
var/DBQuery/update_query = dbcon.NewQuery("UPDATE [format_table_name("memo")] SET memotext = '[new_memo]', last_editor = '[sql_ckey]', edits = CONCAT(IFNULL(edits,''),'[edit_text]') WHERE ckey = '[target_sql_ckey]'")
|
||||
if(!update_query.Execute())
|
||||
var/err = update_query.ErrorMsg()
|
||||
log_game("SQL ERROR editing memo. Error : \[[err]\]\n")
|
||||
return
|
||||
if(target_sql_ckey == sql_ckey)
|
||||
log_admin("[key_name(src)] has edited their memo from [old_memo] to [new_memo]")
|
||||
message_admins("[key_name_admin(src)] has edited their memo from<br>[old_memo]<br>to<br>[new_memo]")
|
||||
else
|
||||
log_admin("[key_name(src)] has edited [target_sql_ckey]'s memo from [old_memo] to [new_memo]")
|
||||
message_admins("[key_name_admin(src)] has edited [target_sql_ckey]'s memo from<br>[old_memo]<br>to<br>[new_memo]")
|
||||
if("Show")
|
||||
var/DBQuery/query_memoshow = dbcon.NewQuery("SELECT ckey, memotext, timestamp, last_editor FROM [format_table_name("memo")]")
|
||||
if(!query_memoshow.Execute())
|
||||
var/err = query_memoshow.ErrorMsg()
|
||||
log_game("SQL ERROR obtaining ckey, memotext, timestamp, last_editor from memo table. Error : \[[err]\]\n")
|
||||
return
|
||||
var/output = null
|
||||
while(query_memoshow.NextRow())
|
||||
var/ckey = query_memoshow.item[1]
|
||||
var/memotext = query_memoshow.item[2]
|
||||
var/timestamp = query_memoshow.item[3]
|
||||
var/last_editor = query_memoshow.item[4]
|
||||
output += "<span class='memo'>Memo by <span class='prefix'>[ckey]</span> on [timestamp]"
|
||||
if(last_editor)
|
||||
output += "<br><span class='memoedit'>Last edit by [last_editor] <A href='?_src_=holder;memoeditlist=[ckey]'>(Click here to see edit log)</A></span>"
|
||||
output += "<br>[memotext]</span><br>"
|
||||
if(!output)
|
||||
src << "No memos found in database."
|
||||
return
|
||||
src << output
|
||||
if("Remove")
|
||||
var/DBQuery/query_memodellist = dbcon.NewQuery("SELECT ckey FROM [format_table_name("memo")]")
|
||||
if(!query_memodellist.Execute())
|
||||
var/err = query_memodellist.ErrorMsg()
|
||||
log_game("SQL ERROR obtaining ckey from memo table. Error : \[[err]\]\n")
|
||||
return
|
||||
var/list/memolist = list()
|
||||
while(query_memodellist.NextRow())
|
||||
var/ckey = query_memodellist.item[1]
|
||||
memolist += "[ckey]"
|
||||
if(!memolist.len)
|
||||
src << "No memos found in database."
|
||||
return
|
||||
var/target_ckey = input(src, "Select whose memo to delete", "Select memo") as null|anything in memolist
|
||||
if(!target_ckey)
|
||||
return
|
||||
var/target_sql_ckey = sanitizeSQL(target_ckey)
|
||||
var/DBQuery/query_memodel = dbcon.NewQuery("DELETE FROM [format_table_name("memo")] WHERE ckey = '[target_sql_ckey]'")
|
||||
if(!query_memodel.Execute())
|
||||
var/err = query_memodel.ErrorMsg()
|
||||
log_game("SQL ERROR removing memo. Error : \[[err]\]\n")
|
||||
return
|
||||
if(target_sql_ckey == sql_ckey)
|
||||
log_admin("[key_name(src)] has removed their memo.")
|
||||
message_admins("[key_name_admin(src)] has removed their memo.")
|
||||
else
|
||||
log_admin("[key_name(src)] has removed [target_sql_ckey]'s memo.")
|
||||
message_admins("[key_name_admin(src)] has removed [target_sql_ckey]'s memo.")
|
||||
@@ -7,7 +7,6 @@ var/list/admin_verbs_default = list(
|
||||
/client/proc/hide_verbs, /*hides all our adminverbs*/
|
||||
/client/proc/hide_most_verbs, /*hides all our hideable adminverbs*/
|
||||
/client/proc/debug_variables, /*allows us to -see- the variables of any instance in the game. +VAREDIT needed to modify*/
|
||||
/client/proc/admin_memo, /*admin memo system. show/delete/write. +SERVER needed to delete admin memos of others*/
|
||||
/client/proc/deadchat, /*toggles deadchat on/off*/
|
||||
/client/proc/dsay, /*talk in deadchat using our ckey/fakekey*/
|
||||
/client/proc/toggleprayers, /*toggles prayers on/off*/
|
||||
|
||||
@@ -76,7 +76,7 @@
|
||||
body += "</td><td align='center'>";
|
||||
|
||||
body += "<a href='?_src_=holder;adminplayeropts="+ref+"'>PP</a> - "
|
||||
body += "<a href='?_src_=holder;shownoteckey="+ckey+"'>N</a> - "
|
||||
body += "<a href='?_src_=holder;showmessageckey="+ckey+"'>N</a> - "
|
||||
body += "<a href='?_src_=vars;Vars="+ref+"'>VV</a> - "
|
||||
body += "<a href='?_src_=holder;traitor="+ref+"'>TP</a> - "
|
||||
body += "<a href='?priv_msg="+ckey+"'>PM</a> - "
|
||||
|
||||
371
code/modules/admin/sql_message_system.dm
Normal file
371
code/modules/admin/sql_message_system.dm
Normal file
@@ -0,0 +1,371 @@
|
||||
/proc/create_message(type, target_ckey, admin_ckey, text, timestamp, server, secret, logged = 1, browse)
|
||||
if(!dbcon.IsConnected())
|
||||
usr << "<span class='danger'>Failed to establish database connection.</span>"
|
||||
return
|
||||
if(!type)
|
||||
return
|
||||
if(!target_ckey && (type == "note" || type == "message" || type == "watchlist entry"))
|
||||
var/new_ckey = ckey(input(usr,"Who would you like to create a [type] for?","Enter a ckey",null) as null|text)
|
||||
if(!new_ckey)
|
||||
return
|
||||
new_ckey = sanitizeSQL(new_ckey)
|
||||
var/DBQuery/query_find_ckey = dbcon.NewQuery("SELECT ckey FROM [format_table_name("player")] WHERE ckey = '[new_ckey]'")
|
||||
if(!query_find_ckey.Execute())
|
||||
var/err = query_find_ckey.ErrorMsg()
|
||||
log_game("SQL ERROR obtaining ckey from player table. Error : \[[err]\]\n")
|
||||
return
|
||||
if(!query_find_ckey.NextRow())
|
||||
if(alert(usr, "[new_ckey] has not been seen before, are you sure you want to create a [type] for them?", "Unknown ckey", "Yes", "No", "Cancel") != "Yes")
|
||||
return
|
||||
target_ckey = new_ckey
|
||||
if(target_ckey)
|
||||
target_ckey = sanitizeSQL(target_ckey)
|
||||
if(!admin_ckey)
|
||||
admin_ckey = usr.ckey
|
||||
if(!admin_ckey)
|
||||
return
|
||||
admin_ckey = sanitizeSQL(admin_ckey)
|
||||
if(!target_ckey)
|
||||
target_ckey = admin_ckey
|
||||
if(!text)
|
||||
text = input(usr,"Write your [type]","Create [type]") as null|message
|
||||
if(!text)
|
||||
return
|
||||
text = sanitizeSQL(text)
|
||||
if(!timestamp)
|
||||
timestamp = SQLtime()
|
||||
if(!server)
|
||||
if (config && config.server_name)
|
||||
server = config.server_name
|
||||
server = sanitizeSQL(server)
|
||||
if(isnull(secret))
|
||||
switch(alert("Hide note from being viewed by players?", "Secret note?","Yes","No","Cancel"))
|
||||
if("Yes")
|
||||
secret = 1
|
||||
if("No")
|
||||
secret = 0
|
||||
else
|
||||
return
|
||||
var/DBQuery/query_create_message = dbcon.NewQuery("INSERT INTO [format_table_name("messages")] (type, targetckey, adminckey, text, timestamp, server, secret) VALUES ('[type]', '[target_ckey]', '[admin_ckey]', '[text]', '[timestamp]', '[server]', '[secret]')")
|
||||
if(!query_create_message.Execute())
|
||||
var/err = query_create_message.ErrorMsg()
|
||||
log_game("SQL ERROR creating new [type] in messages table. Error : \[[err]\]\n")
|
||||
return
|
||||
if(logged)
|
||||
log_admin("[key_name(usr)] has created a [type][type == ("note"||"message"||"watchlist entry") ? " for [target_ckey]" : ""]: [text]")
|
||||
message_admins("[key_name_admin(usr)] has created a [type][type == ("note"||"message"||"watchlist entry") ? " for [target_ckey]" : ""]:<br>[text]")
|
||||
if(browse)
|
||||
browse_messages("[type]")
|
||||
else
|
||||
browse_messages(target_ckey = target_ckey)
|
||||
|
||||
/proc/delete_message(message_id, logged = 1, browse)
|
||||
if(!dbcon.IsConnected())
|
||||
usr << "<span class='danger'>Failed to establish database connection.</span>"
|
||||
return
|
||||
message_id = text2num(message_id)
|
||||
if(!message_id)
|
||||
return
|
||||
var/type
|
||||
var/target_ckey
|
||||
var/text
|
||||
var/DBQuery/query_find_del_message = dbcon.NewQuery("SELECT type, targetckey, adminckey, text FROM [format_table_name("messages")] WHERE id = [message_id]")
|
||||
if(!query_find_del_message.Execute())
|
||||
var/err = query_find_del_message.ErrorMsg()
|
||||
log_game("SQL ERROR obtaining type, targetckey, adminckey text from messages table. Error : \[[err]\]\n")
|
||||
return
|
||||
if(query_find_del_message.NextRow())
|
||||
type = query_find_del_message.item[1]
|
||||
target_ckey = query_find_del_message.item[2]
|
||||
text = query_find_del_message.item[4]
|
||||
var/DBQuery/query_del_message = dbcon.NewQuery("DELETE FROM [format_table_name("messages")] WHERE id = [message_id]")
|
||||
if(!query_del_message.Execute())
|
||||
var/err = query_del_message.ErrorMsg()
|
||||
log_game("SQL ERROR deleting [type] from messages table. Error : \[[err]\]\n")
|
||||
return
|
||||
if(logged)
|
||||
log_admin("[key_name(usr)] has deleted a [type][type == ("note"||"message"||"watchlist entry") ? " for" : " made by"] [target_ckey]: [text]")
|
||||
message_admins("[key_name_admin(usr)] has deleted a [type][type == ("note"||"message"||"watchlist entry") ? " for" : " made by"] [target_ckey]:<br>[text]")
|
||||
if(browse)
|
||||
browse_messages("[type]")
|
||||
else
|
||||
browse_messages(target_ckey = target_ckey)
|
||||
|
||||
/proc/edit_message(message_id, browse)
|
||||
if(!dbcon.IsConnected())
|
||||
usr << "<span class='danger'>Failed to establish database connection.</span>"
|
||||
return
|
||||
message_id = text2num(message_id)
|
||||
if(!message_id)
|
||||
return
|
||||
var/DBQuery/query_find_edit_message = dbcon.NewQuery("SELECT type, targetckey, adminckey, text FROM [format_table_name("messages")] WHERE id = [message_id]")
|
||||
if(!query_find_edit_message.Execute())
|
||||
var/err = query_find_edit_message.ErrorMsg()
|
||||
log_game("SQL ERROR obtaining type, targetckey, adminckey, text from messages table. Error : \[[err]\]\n")
|
||||
return
|
||||
if(query_find_edit_message.NextRow())
|
||||
var/type = query_find_edit_message.item[1]
|
||||
var/target_ckey = query_find_edit_message.item[2]
|
||||
var/admin_ckey = query_find_edit_message.item[3]
|
||||
var/old_text = query_find_edit_message.item[4]
|
||||
var/editor_ckey = sanitizeSQL(usr.ckey)
|
||||
var/new_text = input("Input new [type]", "New [type]", "[old_text]") as null|message
|
||||
if(!new_text)
|
||||
return
|
||||
new_text = sanitizeSQL(new_text)
|
||||
var/edit_text = sanitizeSQL("Edited by [editor_ckey] on [SQLtime()] from<br>[old_text]<br>to<br>[new_text]<hr>")
|
||||
var/DBQuery/query_edit_message = dbcon.NewQuery("UPDATE [format_table_name("messages")] SET text = '[new_text]', lasteditor = '[editor_ckey]', edits = CONCAT(IFNULL(edits,''),'[edit_text]') WHERE id = [message_id]")
|
||||
if(!query_edit_message.Execute())
|
||||
var/err = query_edit_message.ErrorMsg()
|
||||
log_game("SQL ERROR editing messages table. Error : \[[err]\]\n")
|
||||
return
|
||||
log_admin("[key_name(usr)] has edited a [type] [type == ("note"||"message"||"watchlist entry") ? " for [target_ckey]" : ""] made by [admin_ckey] from [old_text] to [new_text]")
|
||||
message_admins("[key_name_admin(usr)] has edited a [type] [type == ("note"||"message"||"watchlist entry") ? " for [target_ckey]" : ""] made by [admin_ckey] from<br>[old_text]<br>to<br>[new_text]")
|
||||
if(browse)
|
||||
browse_messages("[type]")
|
||||
else
|
||||
browse_messages(target_ckey = target_ckey)
|
||||
|
||||
/proc/toggle_message_secrecy(message_id)
|
||||
if(!dbcon.IsConnected())
|
||||
usr << "<span class='danger'>Failed to establish database connection.</span>"
|
||||
return
|
||||
message_id = text2num(message_id)
|
||||
if(!message_id)
|
||||
return
|
||||
var/DBQuery/query_find_message_secret = dbcon.NewQuery("SELECT type, targetckey, adminckey, secret FROM [format_table_name("messages")] WHERE id = [message_id]")
|
||||
if(!query_find_message_secret.Execute())
|
||||
var/err = query_find_message_secret.ErrorMsg()
|
||||
log_game("SQL ERROR obtaining type, targetckey, adminckey, secret from messages table. Error : \[[err]\]\n")
|
||||
return
|
||||
if(query_find_message_secret.NextRow())
|
||||
var/type = query_find_message_secret.item[1]
|
||||
var/target_ckey = query_find_message_secret.item[2]
|
||||
var/admin_ckey = query_find_message_secret.item[3]
|
||||
var/secret = text2num(query_find_message_secret.item[4])
|
||||
var/editor_ckey = sanitizeSQL(usr.ckey)
|
||||
var/edit_text = "Made [secret ? "not secret" : "secret"] by [editor_ckey] on [SQLtime()]<hr>"
|
||||
var/DBQuery/query_message_secret = dbcon.NewQuery("UPDATE [format_table_name("messages")] SET secret = NOT secret, lasteditor = '[editor_ckey]', edits = CONCAT(IFNULL(edits,''),'[edit_text]') WHERE id = [message_id]")
|
||||
if(!query_message_secret.Execute())
|
||||
var/err = query_message_secret.ErrorMsg()
|
||||
log_game("SQL ERROR toggling message secrecy. Error : \[[err]\]\n")
|
||||
return
|
||||
log_admin("[key_name(usr)] has toggled [target_ckey]'s [type] made by [admin_ckey] to [secret ? "not secret" : "secret"]")
|
||||
message_admins("[key_name_admin(usr)] has toggled [target_ckey]'s [type] made by [admin_ckey] to [secret ? "not secret" : "secret"]")
|
||||
browse_messages(target_ckey = target_ckey)
|
||||
|
||||
/proc/browse_messages(type, target_ckey, index, linkless = 0)
|
||||
if(!dbcon.IsConnected())
|
||||
usr << "<span class='danger'>Failed to establish database connection.</span>"
|
||||
return
|
||||
var/output
|
||||
var/ruler = "<hr style='background:#000000; border:0; height:3px'>"
|
||||
var/navbar = "<a href='?_src_=holder;nonalpha=1'>\[All\]</a>|<a href='?_src_=holder;nonalpha=2'>\[#\]</a>"
|
||||
for(var/letter in alphabet)
|
||||
navbar += "|<a href='?_src_=holder;showmessages=[letter]'>\[[letter]\]</a>"
|
||||
navbar += "|<a href='?_src_=holder;showmemo=1'>\[Memos\]</a>|<a href='?_src_=holder;showwatch=1'>\[Watchlist\]</a>"
|
||||
navbar += "<br><form method='GET' name='search' action='?'>\
|
||||
<input type='hidden' name='_src_' value='holder'>\
|
||||
<input type='text' name='searchmessages' value='[index]'>\
|
||||
<input type='submit' value='Search'></form>"
|
||||
if(!linkless)
|
||||
output = navbar
|
||||
if(type == "memo" || type == "watchlist entry")
|
||||
if(type == "memo")
|
||||
output += "<h2><center>Admin memos</h2>"
|
||||
output += "<a href='?_src_=holder;addmemo=1'>\[Add memo\]</a></center>"
|
||||
else if(type == "watchlist entry")
|
||||
output += "<h2><center>Watchlist entries</h2>"
|
||||
output += "<a href='?_src_=holder;addwatchempty=1'>\[Add watchlist entry\]</a></center>"
|
||||
output += ruler
|
||||
var/DBQuery/query_get_type_messages = dbcon.NewQuery("SELECT id, targetckey, adminckey, text, timestamp, server, lasteditor FROM [format_table_name("messages")] WHERE type = '[type]'")
|
||||
if(!query_get_type_messages.Execute())
|
||||
var/err = query_get_type_messages.ErrorMsg()
|
||||
log_game("SQL ERROR obtaining id, targetckey, adminckey, text, timestamp, server, lasteditor from messages table. Error : \[[err]\]\n")
|
||||
return
|
||||
while(query_get_type_messages.NextRow())
|
||||
var/id = query_get_type_messages.item[1]
|
||||
var/t_ckey = query_get_type_messages.item[2]
|
||||
var/admin_ckey = query_get_type_messages.item[3]
|
||||
var/text = query_get_type_messages.item[4]
|
||||
var/timestamp = query_get_type_messages.item[5]
|
||||
var/server = query_get_type_messages.item[6]
|
||||
var/editor_ckey = query_get_type_messages.item[7]
|
||||
output += "<b>"
|
||||
if(type == "watchlist entry")
|
||||
output += "[t_ckey] | "
|
||||
output += "[timestamp] | [server] | [admin_ckey]</b>"
|
||||
output += " <a href='?_src_=holder;deletemessageempty=[id]'>\[Delete\]</a>"
|
||||
output += " <a href='?_src_=holder;editmessageempty=[id]'>\[Edit\]</a>"
|
||||
if(editor_ckey)
|
||||
output += " <font size='2'>Last edit by [editor_ckey] <a href='?_src_=holder;messageedits=[id]'>(Click here to see edit log)</a></font>"
|
||||
output += "<br>[text]<hr style='background:#000000; border:0; height:1px'>"
|
||||
if(target_ckey)
|
||||
target_ckey = sanitizeSQL(target_ckey)
|
||||
var/DBQuery/query_get_messages = dbcon.NewQuery("SELECT type, secret, id, adminckey, text, timestamp, server, lasteditor FROM [format_table_name("messages")] WHERE type <> 'memo' AND targetckey = '[target_ckey]' ORDER BY timestamp")
|
||||
if(!query_get_messages.Execute())
|
||||
var/err = query_get_messages.ErrorMsg()
|
||||
log_game("SQL ERROR obtaining type, secret, id, adminckey, text, timestamp, server, lasteditor from messages table. Error : \[[err]\]\n")
|
||||
return
|
||||
var/messagedata
|
||||
var/watchdata
|
||||
var/notedata
|
||||
while(query_get_messages.NextRow())
|
||||
type = query_get_messages.item[1]
|
||||
if(type == "memo")
|
||||
continue
|
||||
var/secret = text2num(query_get_messages.item[2])
|
||||
if(linkless && secret)
|
||||
continue
|
||||
var/id = query_get_messages.item[3]
|
||||
var/admin_ckey = query_get_messages.item[4]
|
||||
var/text = query_get_messages.item[5]
|
||||
var/timestamp = query_get_messages.item[6]
|
||||
var/server = query_get_messages.item[7]
|
||||
var/editor_ckey = query_get_messages.item[8]
|
||||
var/data
|
||||
data += "<b>[timestamp] | [server] | [admin_ckey]</b>"
|
||||
if(!linkless)
|
||||
data += " <a href='?_src_=holder;deletemessage=[id]'>\[Delete\]</a>"
|
||||
if(type == "note")
|
||||
data += " <a href='?_src_=holder;secretmessage=[id]'>[secret ? "<b>\[Secret\]</b>" : "\[Not secret\]"]</a>"
|
||||
data += " <a href='?_src_=holder;editmessage=[id]'>\[Edit\]</a>"
|
||||
if(editor_ckey)
|
||||
data += " <font size='2'>Last edit by [editor_ckey] <a href='?_src_=holder;messageedits=[id]'>(Click here to see edit log)</a></font>"
|
||||
data += "<br>[text]<hr style='background:#000000; border:0; height:1px'>"
|
||||
switch(type)
|
||||
if("message")
|
||||
messagedata += data
|
||||
if("watchlist entry")
|
||||
watchdata += data
|
||||
if("note")
|
||||
notedata += data
|
||||
output += "<h2><center>[target_ckey]</center></h2><center>"
|
||||
if(!linkless)
|
||||
output += "<a href='?_src_=holder;addmessage=[target_ckey]'>\[Add message\]</a>"
|
||||
output += " <a href='?_src_=holder;addwatch=[target_ckey]'>\[Add to watchlist\]</a>"
|
||||
output += " <a href='?_src_=holder;addnote=[target_ckey]'>\[Add note\]</a>"
|
||||
output += " <a href='?_src_=holder;showmessageckey=[target_ckey]'>\[Refresh page\]</a></center>"
|
||||
else
|
||||
output += " <a href='?_src_=holder;showmessageckeylinkless=[target_ckey]'>\[Refresh page\]</a></center>"
|
||||
output += ruler
|
||||
if(messagedata)
|
||||
output += "<h4>Messages</h4>"
|
||||
output += messagedata
|
||||
if(watchdata)
|
||||
output += "<h4>Watchlist</h4>"
|
||||
output += watchdata
|
||||
if(notedata)
|
||||
output += "<h4>Notes</h4>"
|
||||
output += notedata
|
||||
if(index)
|
||||
var/index_ckey
|
||||
var/search
|
||||
output += "<center><a href='?_src_=holder;addmessageempty=1'>\[Add message\]</a><a href='?_src_=holder;addwatchempty=1'>\[Add watchlist entry\]</a><a href='?_src_=holder;addnoteempty=1'>\[Add note\]</a></center>"
|
||||
output += ruler
|
||||
if(!isnum(index))
|
||||
index = sanitizeSQL(index)
|
||||
switch(index)
|
||||
if(1)
|
||||
search = "^."
|
||||
if(2)
|
||||
search = "^\[^\[:alpha:\]\]"
|
||||
else
|
||||
search = "^[index]"
|
||||
var/DBQuery/query_list_messages = dbcon.NewQuery("SELECT DISTINCT targetckey FROM [format_table_name("messages")] WHERE type <> 'memo' AND targetckey REGEXP '[search]' ORDER BY targetckey")
|
||||
if(!query_list_messages.Execute())
|
||||
var/err = query_list_messages.ErrorMsg()
|
||||
log_game("SQL ERROR obtaining distinct targetckey from messages table. Error : \[[err]\]\n")
|
||||
return
|
||||
while(query_list_messages.NextRow())
|
||||
index_ckey = query_list_messages.item[1]
|
||||
output += "<a href='?_src_=holder;showmessageckey=[index_ckey]'>[index_ckey]</a><br>"
|
||||
else if(!type && !target_ckey && !index)
|
||||
output += "<center></a> <a href='?_src_=holder;addmessageempty=1'>\[Add message\]</a><a href='?_src_=holder;addwatchempty=1'>\[Add watchlist entry\]</a><a href='?_src_=holder;addnoteempty=1'>\[Add note\]</a></center>"
|
||||
output += ruler
|
||||
usr << browse(output, "window=browse_messages;size=900x500")
|
||||
|
||||
proc/get_message_output(type, target_ckey)
|
||||
if(!dbcon.IsConnected())
|
||||
usr << "<span class='danger'>Failed to establish database connection.</span>"
|
||||
return
|
||||
if(!type)
|
||||
return
|
||||
var/output
|
||||
if(target_ckey)
|
||||
target_ckey = sanitizeSQL(target_ckey)
|
||||
var/query = "SELECT id, adminckey, text, timestamp, lasteditor FROM [format_table_name("messages")] WHERE type = '[type]'"
|
||||
if(type == "message" || type == "watchlist entry")
|
||||
query += " AND targetckey = '[target_ckey]'"
|
||||
var/DBQuery/query_get_message_output = dbcon.NewQuery(query)
|
||||
if(!query_get_message_output.Execute())
|
||||
var/err = query_get_message_output.ErrorMsg()
|
||||
log_game("SQL ERROR obtaining id, adminckey, text, timestamp, lasteditor from messages table. Error : \[[err]\]\n")
|
||||
return
|
||||
while(query_get_message_output.NextRow())
|
||||
var/id = query_get_message_output.item[1]
|
||||
var/admin_ckey = query_get_message_output.item[2]
|
||||
var/text = query_get_message_output.item[3]
|
||||
var/timestamp = query_get_message_output.item[4]
|
||||
var/editor_ckey = query_get_message_output.item[5]
|
||||
switch(type)
|
||||
if("message")
|
||||
output += "<font color='red' size='3'><b>Admin message left by <span class='prefix'>[admin_ckey]</span> on [timestamp]</b></font>"
|
||||
output += "<br><font color='red'>[text]</font>"
|
||||
delete_message(id, 0)
|
||||
if("watchlist entry")
|
||||
message_admins("<font color='red'><B>Notice: </B></font><font color='blue'>[key_name_admin(target_ckey)] is on the watchlist and has just connected - Reason: [text]</font>")
|
||||
send2irc_adminless_only("Watchlist", "[key_name(target_ckey)] is on the watchlist and has just connected - Reason: [text]")
|
||||
if("memo")
|
||||
output += "<span class='memo'>Memo by <span class='prefix'>[admin_ckey]</span> on [timestamp]"
|
||||
if(editor_ckey)
|
||||
output += "<br><span class='memoedit'>Last edit by [editor_ckey] <A href='?_src_=holder;messageedits=[id]'>(Click here to see edit log)</A></span>"
|
||||
output += "<br>[text]</span><br>"
|
||||
return output
|
||||
|
||||
#define NOTESFILE "data/player_notes.sav"
|
||||
//if the AUTOCONVERT_NOTES is turned on, anytime a player connects this will be run to try and add all their notes to the databas
|
||||
/proc/convert_notes_sql(ckey)
|
||||
var/savefile/notesfile = new(NOTESFILE)
|
||||
if(!notesfile)
|
||||
log_game("Error: Cannot access [NOTESFILE]")
|
||||
return
|
||||
notesfile.cd = "/[ckey]"
|
||||
while(!notesfile.eof)
|
||||
var/notetext
|
||||
notesfile >> notetext
|
||||
var/server
|
||||
if(config && config.server_name)
|
||||
server = config.server_name
|
||||
var/regex/note = new("^(\\d{2}-\\w{3}-\\d{4}) \\| (.+) ~(\\w+)$", "i")
|
||||
note.Find(notetext)
|
||||
var/timestamp = note.group[1]
|
||||
notetext = note.group[2]
|
||||
var/admin_ckey = note.group[3]
|
||||
var/DBQuery/query_convert_time = dbcon.NewQuery("SELECT ADDTIME(STR_TO_DATE('[timestamp]','%d-%b-%Y'), '0')")
|
||||
if(!query_convert_time.Execute())
|
||||
var/err = query_convert_time.ErrorMsg()
|
||||
log_game("SQL ERROR converting timestamp. Error : \[[err]\]\n")
|
||||
return
|
||||
if(query_convert_time.NextRow())
|
||||
timestamp = query_convert_time.item[1]
|
||||
if(ckey && notetext && timestamp && admin_ckey && server)
|
||||
create_message("note", ckey, admin_ckey, notetext, timestamp, server, 1, 0)
|
||||
notesfile.cd = "/"
|
||||
notesfile.dir.Remove(ckey)
|
||||
|
||||
/*alternatively this proc can be run once to pass through every note and attempt to convert it before deleting the file, if done then AUTOCONVERT_NOTES should be turned off
|
||||
this proc can take several minutes to execute fully if converting and cause DD to hang if converting a lot of notes; it's not advised to do so while a server is live
|
||||
/proc/mass_convert_notes()
|
||||
world << "Beginning mass note conversion"
|
||||
var/savefile/notesfile = new(NOTESFILE)
|
||||
if(!notesfile)
|
||||
log_game("Error: Cannot access [NOTESFILE]")
|
||||
return
|
||||
notesfile.cd = "/"
|
||||
for(var/ckey in notesfile.dir)
|
||||
convert_notes_sql(ckey)
|
||||
world << "Deleting NOTESFILE"
|
||||
fdel(NOTESFILE)
|
||||
world << "Finished mass note conversion, remember to turn off AUTOCONVERT_NOTES"*/
|
||||
#undef NOTESFILE
|
||||
@@ -1,260 +0,0 @@
|
||||
/proc/add_note(target_ckey, notetext, timestamp, adminckey, logged = 1, server, secret)
|
||||
if(!dbcon.IsConnected())
|
||||
usr << "<span class='danger'>Failed to establish database connection.</span>"
|
||||
return
|
||||
if(!target_ckey)
|
||||
var/new_ckey = ckey(input(usr,"Who would you like to add a note for?","Enter a ckey",null) as text)
|
||||
if(!new_ckey)
|
||||
return
|
||||
new_ckey = sanitizeSQL(new_ckey)
|
||||
var/DBQuery/query_find_ckey = dbcon.NewQuery("SELECT ckey FROM [format_table_name("player")] WHERE ckey = '[new_ckey]'")
|
||||
if(!query_find_ckey.Execute())
|
||||
var/err = query_find_ckey.ErrorMsg()
|
||||
log_game("SQL ERROR obtaining ckey from player table. Error : \[[err]\]\n")
|
||||
return
|
||||
if(!query_find_ckey.NextRow())
|
||||
if(alert(usr, "[new_ckey] has not been seen before, are you sure you want to add a note for them?", "Unknown ckey", "Yes", "No", "Cancel") != "Yes")
|
||||
return
|
||||
target_ckey = new_ckey
|
||||
var/target_sql_ckey = sanitizeSQL(target_ckey)
|
||||
if(!notetext)
|
||||
notetext = input(usr,"Write your Note","Add Note") as null|message
|
||||
if(!notetext)
|
||||
return
|
||||
notetext = sanitizeSQL(notetext)
|
||||
if(!timestamp)
|
||||
timestamp = SQLtime()
|
||||
if(!adminckey)
|
||||
adminckey = usr.ckey
|
||||
if(!adminckey)
|
||||
return
|
||||
var/admin_sql_ckey = sanitizeSQL(adminckey)
|
||||
if(!server)
|
||||
if (config && config.server_name)
|
||||
server = config.server_name
|
||||
server = sanitizeSQL(server)
|
||||
if(isnull(secret))
|
||||
switch(alert("Hide note from being viewed by players?", "Secret Note?","Yes","No","Cancel"))
|
||||
if("Yes")
|
||||
secret = 1
|
||||
if("No")
|
||||
secret = 0
|
||||
else
|
||||
return
|
||||
var/DBQuery/query_noteadd = dbcon.NewQuery("INSERT INTO [format_table_name("notes")] (ckey, timestamp, notetext, adminckey, server, secret) VALUES ('[target_sql_ckey]', '[timestamp]', '[notetext]', '[admin_sql_ckey]', '[server]', '[secret]')")
|
||||
if(!query_noteadd.Execute())
|
||||
var/err = query_noteadd.ErrorMsg()
|
||||
log_game("SQL ERROR adding new note to table. Error : \[[err]\]\n")
|
||||
return
|
||||
if(logged)
|
||||
log_admin("[key_name(usr)] has added a note to [target_ckey]: [notetext]")
|
||||
message_admins("[key_name_admin(usr)] has added a note to [target_ckey]:<br>[notetext]")
|
||||
show_note(target_ckey)
|
||||
|
||||
/proc/remove_note(note_id)
|
||||
var/ckey
|
||||
var/notetext
|
||||
var/adminckey
|
||||
if(!dbcon.IsConnected())
|
||||
usr << "<span class='danger'>Failed to establish database connection.</span>"
|
||||
return
|
||||
if(!note_id)
|
||||
return
|
||||
note_id = text2num(note_id)
|
||||
var/DBQuery/query_find_note_del = dbcon.NewQuery("SELECT ckey, notetext, adminckey FROM [format_table_name("notes")] WHERE id = [note_id]")
|
||||
if(!query_find_note_del.Execute())
|
||||
var/err = query_find_note_del.ErrorMsg()
|
||||
log_game("SQL ERROR obtaining ckey, notetext, adminckey from notes table. Error : \[[err]\]\n")
|
||||
return
|
||||
if(query_find_note_del.NextRow())
|
||||
ckey = query_find_note_del.item[1]
|
||||
notetext = query_find_note_del.item[2]
|
||||
adminckey = query_find_note_del.item[3]
|
||||
var/DBQuery/query_del_note = dbcon.NewQuery("DELETE FROM [format_table_name("notes")] WHERE id = [note_id]")
|
||||
if(!query_del_note.Execute())
|
||||
var/err = query_del_note.ErrorMsg()
|
||||
log_game("SQL ERROR removing note from table. Error : \[[err]\]\n")
|
||||
return
|
||||
log_admin("[key_name(usr)] has removed a note made by [adminckey] from [ckey]: [notetext]")
|
||||
message_admins("[key_name_admin(usr)] has removed a note made by [adminckey] from [ckey]:<br>[notetext]")
|
||||
show_note(ckey)
|
||||
|
||||
/proc/edit_note(note_id)
|
||||
if(!dbcon.IsConnected())
|
||||
usr << "<span class='danger'>Failed to establish database connection.</span>"
|
||||
return
|
||||
if(!note_id)
|
||||
return
|
||||
note_id = text2num(note_id)
|
||||
var/target_ckey
|
||||
var/sql_ckey = sanitizeSQL(usr.ckey)
|
||||
var/DBQuery/query_find_note_edit = dbcon.NewQuery("SELECT ckey, notetext, adminckey FROM [format_table_name("notes")] WHERE id = [note_id]")
|
||||
if(!query_find_note_edit.Execute())
|
||||
var/err = query_find_note_edit.ErrorMsg()
|
||||
log_game("SQL ERROR obtaining notetext from notes table. Error : \[[err]\]\n")
|
||||
return
|
||||
if(query_find_note_edit.NextRow())
|
||||
target_ckey = query_find_note_edit.item[1]
|
||||
var/old_note = query_find_note_edit.item[2]
|
||||
var/adminckey = query_find_note_edit.item[3]
|
||||
var/new_note = input("Input new note", "New Note", "[old_note]") as null|message
|
||||
if(!new_note)
|
||||
return
|
||||
new_note = sanitizeSQL(new_note)
|
||||
var/edit_text = "Edited by [sql_ckey] on [SQLtime()] from<br>[old_note]<br>to<br>[new_note]<hr>"
|
||||
edit_text = sanitizeSQL(edit_text)
|
||||
var/DBQuery/query_update_note = dbcon.NewQuery("UPDATE [format_table_name("notes")] SET notetext = '[new_note]', last_editor = '[sql_ckey]', edits = CONCAT(IFNULL(edits,''),'[edit_text]') WHERE id = [note_id]")
|
||||
if(!query_update_note.Execute())
|
||||
var/err = query_update_note.ErrorMsg()
|
||||
log_game("SQL ERROR editing note. Error : \[[err]\]\n")
|
||||
return
|
||||
log_admin("[key_name(usr)] has edited [target_ckey]'s note made by [adminckey] from [old_note] to [new_note]")
|
||||
message_admins("[key_name_admin(usr)] has edited [target_ckey]'s note made by [adminckey] from<br>[old_note]<br>to<br>[new_note]")
|
||||
show_note(target_ckey)
|
||||
|
||||
/proc/toggle_note_secrecy(note_id)
|
||||
if(!dbcon.IsConnected())
|
||||
usr << "<span class='danger'>Failed to establish database connection.</span>"
|
||||
return
|
||||
if(!note_id)
|
||||
return
|
||||
note_id = text2num(note_id)
|
||||
var/DBQuery/query_find_note_secret = dbcon.NewQuery("SELECT ckey, adminckey, secret FROM [format_table_name("notes")] WHERE id = [note_id]")
|
||||
if(!query_find_note_secret.Execute())
|
||||
var/err = query_find_note_secret.ErrorMsg()
|
||||
log_game("SQL ERROR obtaining ckey, adminckey, secret from notes table. Error : \[[err]\]\n")
|
||||
return
|
||||
if(query_find_note_secret.NextRow())
|
||||
var/target_ckey = query_find_note_secret.item[1]
|
||||
var/adminckey = query_find_note_secret.item[2]
|
||||
var/secret = text2num(query_find_note_secret.item[3])
|
||||
var/sql_ckey = sanitizeSQL(usr.ckey)
|
||||
var/edit_text = "Made [secret ? "not secret" : "secret"] by [sql_ckey] on [SQLtime()]<hr>"
|
||||
var/DBQuery/query_update_note = dbcon.NewQuery("UPDATE [format_table_name("notes")] SET secret = NOT secret, last_editor = '[sql_ckey]', edits = CONCAT(IFNULL(edits,''),'[edit_text]') WHERE id = [note_id]")
|
||||
if(!query_update_note.Execute())
|
||||
var/err = query_update_note.ErrorMsg()
|
||||
log_game("SQL ERROR toggling note secrecy. Error : \[[err]\]\n")
|
||||
return
|
||||
log_admin("[key_name(usr)] has toggled [target_ckey]'s note made by [adminckey] to [secret ? "not secret" : "secret"]")
|
||||
message_admins("[key_name_admin(usr)] has toggled [target_ckey]'s note made by [adminckey] to [secret ? "not secret" : "secret"]")
|
||||
show_note(target_ckey)
|
||||
|
||||
/proc/show_note(target_ckey, index, linkless = 0)
|
||||
if(!dbcon.IsConnected())
|
||||
usr << "<span class='danger'>Failed to establish database connection.</span>"
|
||||
return
|
||||
var/output
|
||||
var/ruler = "<hr style='background:#000000; border:0; height:3px'>"
|
||||
var/navbar = "<a href='?_src_=holder;nonalpha=1'>\[All\]</a>|<a href='?_src_=holder;nonalpha=2'>\[#\]</a>"
|
||||
for(var/letter in alphabet)
|
||||
navbar += "|<a href='?_src_=holder;shownote=[letter]'>\[[letter]\]</a>"
|
||||
navbar += "<br><form method='GET' name='search' action='?'>\
|
||||
<input type='hidden' name='_src_' value='holder'>\
|
||||
<input type='text' name='notessearch' value='[index]'>\
|
||||
<input type='submit' value='Search'></form>"
|
||||
if(!linkless)
|
||||
output = navbar
|
||||
if(target_ckey)
|
||||
var/target_sql_ckey = sanitizeSQL(target_ckey)
|
||||
var/DBQuery/query_get_notes = dbcon.NewQuery("SELECT secret, timestamp, notetext, adminckey, last_editor, server, id FROM [format_table_name("notes")] WHERE ckey = '[target_sql_ckey]' ORDER BY timestamp")
|
||||
if(!query_get_notes.Execute())
|
||||
var/err = query_get_notes.ErrorMsg()
|
||||
usr << "<span class='danger'>SQL ERROR: Failed to obtain DB records. Error : \[[err]\]\</span>"
|
||||
log_game("SQL ERROR obtaining secret, timestamp, notetext, adminckey, last_editor, server, id from notes table. Error : \[[err]\]\n")
|
||||
return
|
||||
output += "<h2><center>Notes of [target_ckey]</center></h2>"
|
||||
if(!linkless)
|
||||
output += "<center><a href='?_src_=holder;addnote=[target_ckey]'>\[Add Note\]</a>"
|
||||
output += " <a href='?_src_=holder;shownoteckey=[target_ckey]'>\[Refresh Page\]</a></center>"
|
||||
else
|
||||
output += " <a href='?_src_=holder;shownoteckeylinkless=[target_ckey]'>\[Refresh Page\]</a></center>"
|
||||
output += ruler
|
||||
while(query_get_notes.NextRow())
|
||||
var/secret = text2num(query_get_notes.item[1])
|
||||
if(linkless && secret)
|
||||
continue
|
||||
var/timestamp = query_get_notes.item[2]
|
||||
var/notetext = query_get_notes.item[3]
|
||||
var/adminckey = query_get_notes.item[4]
|
||||
var/last_editor = query_get_notes.item[5]
|
||||
var/server = query_get_notes.item[6]
|
||||
var/id = query_get_notes.item[7]
|
||||
output += "<b>[timestamp] | [server] | [adminckey]</b>"
|
||||
if(!linkless)
|
||||
output += " <a href='?_src_=holder;removenote=[id]'>\[Remove Note\]</a> <a href='?_src_=holder;secretnote=[id]'>[secret ? "<b>\[Secret\]</b>" : "\[Not Secret\]"]</a> <a href='?_src_=holder;editnote=[id]'>\[Edit Note\]</a>"
|
||||
if(last_editor)
|
||||
output += " <font size='2'>Last edit by [last_editor] <a href='?_src_=holder;noteedits=[id]'>(Click here to see edit log)</a></font>"
|
||||
output += "<br>[notetext]<hr style='background:#000000; border:0; height:1px'>"
|
||||
else if(index)
|
||||
var/index_ckey
|
||||
var/search
|
||||
output += "<center><a href='?_src_=holder;addnoteempty=1'>\[Add Note\]</a></center>"
|
||||
output += ruler
|
||||
if(!isnum(index))
|
||||
index = sanitizeSQL(index)
|
||||
switch(index)
|
||||
if(1)
|
||||
search = "^."
|
||||
if(2)
|
||||
search = "^\[^\[:alpha:\]\]"
|
||||
else
|
||||
search = "^[index]"
|
||||
var/DBQuery/query_list_notes = dbcon.NewQuery("SELECT DISTINCT ckey FROM [format_table_name("notes")] WHERE ckey REGEXP '[search]' ORDER BY ckey")
|
||||
if(!query_list_notes.Execute())
|
||||
var/err = query_list_notes.ErrorMsg()
|
||||
log_game("SQL ERROR obtaining ckey from notes table. Error : \[[err]\]\n")
|
||||
return
|
||||
while(query_list_notes.NextRow())
|
||||
index_ckey = query_list_notes.item[1]
|
||||
output += "<a href='?_src_=holder;shownoteckey=[index_ckey]'>[index_ckey]</a><br>"
|
||||
else
|
||||
output += "<center><a href='?_src_=holder;addnoteempty=1'>\[Add Note\]</a></center>"
|
||||
output += ruler
|
||||
usr << browse(output, "window=show_notes;size=900x500")
|
||||
|
||||
#define NOTESFILE "data/player_notes.sav"
|
||||
//if the AUTOCONVERT_NOTES is turned on, anytime a player connects this will be run to try and add all their notes to the databas
|
||||
/proc/convert_notes_sql(ckey)
|
||||
var/savefile/notesfile = new(NOTESFILE)
|
||||
if(!notesfile)
|
||||
log_game("Error: Cannot access [NOTESFILE]")
|
||||
return
|
||||
notesfile.cd = "/[ckey]"
|
||||
while(!notesfile.eof)
|
||||
var/notetext
|
||||
notesfile >> notetext
|
||||
var/server
|
||||
if(config && config.server_name)
|
||||
server = config.server_name
|
||||
var/regex/note = new("^(\\d{2}-\\w{3}-\\d{4}) \\| (.+) ~(\\w+)$", "i")
|
||||
note.Find(notetext)
|
||||
var/timestamp = note.group[1]
|
||||
notetext = note.group[2]
|
||||
var/adminckey = note.group[3]
|
||||
var/DBQuery/query_convert_time = dbcon.NewQuery("SELECT ADDTIME(STR_TO_DATE('[timestamp]','%d-%b-%Y'), '0')")
|
||||
if(!query_convert_time.Execute())
|
||||
var/err = query_convert_time.ErrorMsg()
|
||||
log_game("SQL ERROR converting timestamp. Error : \[[err]\]\n")
|
||||
return
|
||||
if(query_convert_time.NextRow())
|
||||
timestamp = query_convert_time.item[1]
|
||||
if(ckey && notetext && timestamp && adminckey && server)
|
||||
add_note(ckey, notetext, timestamp, adminckey, 0, server, 1)
|
||||
notesfile.cd = "/"
|
||||
notesfile.dir.Remove(ckey)
|
||||
|
||||
/*alternatively this proc can be run once to pass through every note and attempt to convert it before deleting the file, if done then AUTOCONVERT_NOTES should be turned off
|
||||
this proc can take several minutes to execute fully if converting and cause DD to hang if converting a lot of notes; it's not advised to do so while a server is live
|
||||
/proc/mass_convert_notes()
|
||||
world << "Beginning mass note conversion"
|
||||
var/savefile/notesfile = new(NOTESFILE)
|
||||
if(!notesfile)
|
||||
log_game("Error: Cannot access [NOTESFILE]")
|
||||
return
|
||||
notesfile.cd = "/"
|
||||
for(var/ckey in notesfile.dir)
|
||||
convert_notes_sql(ckey)
|
||||
world << "Deleting NOTESFILE"
|
||||
fdel(NOTESFILE)
|
||||
world << "Finished mass note conversion, remember to turn off AUTOCONVERT_NOTES"*/
|
||||
#undef NOTESFILE
|
||||
@@ -238,7 +238,7 @@
|
||||
if(!DB_ban_record(bantype, playermob, banduration, banreason, banjob, null, banckey, banip, bancid ))
|
||||
usr << "<span class='danger'>Failed to apply ban.</span>"
|
||||
return
|
||||
add_note(banckey, banreason, null, usr.ckey, 0, null, 0)
|
||||
create_message("note", banckey, null, banreason, null, null, 0, 0)
|
||||
|
||||
else if(href_list["editrights"])
|
||||
edit_rights_topic(href_list)
|
||||
@@ -543,7 +543,7 @@
|
||||
ban_unban_log_save("[key_name(usr)] appearance banned [key_name(M)]. reason: [reason]")
|
||||
log_admin("[key_name(usr)] appearance banned [key_name(M)]. \nReason: [reason]")
|
||||
feedback_inc("ban_appearance",1)
|
||||
add_note(M.ckey, "Appearance banned - [reason]", null, usr.ckey, 0, null, 0)
|
||||
create_message("note", M.ckey, null, "Appearance banned - [reason]", null, null, 0, 0)
|
||||
message_admins("<span class='adminnotice'>[key_name_admin(usr)] appearance banned [key_name_admin(M)].</span>")
|
||||
M << "<span class='boldannounce'><BIG>You have been appearance banned by [usr.client.ckey].</BIG></span>"
|
||||
M << "<span class='boldannounce'>The reason is: [reason]</span>"
|
||||
@@ -933,7 +933,7 @@
|
||||
msg = job
|
||||
else
|
||||
msg += ", [job]"
|
||||
add_note(M.ckey, "Banned from [msg] - [reason]", null, usr.ckey, 0, null, 0)
|
||||
create_message("note", M.ckey, null, "Banned from [msg] - [reason]", null, null, 0, 0)
|
||||
message_admins("<span class='adminnotice'>[key_name_admin(usr)] banned [key_name_admin(M)] from [msg] for [mins] minutes.</span>")
|
||||
M << "<span class='boldannounce'><BIG>You have been [(msg == ("ooc" || "appearance")) ? "banned" : "jobbanned"] by [usr.client.ckey] from: [msg].</BIG></span>"
|
||||
M << "<span class='boldannounce'>The reason is: [reason]</span>"
|
||||
@@ -958,7 +958,7 @@
|
||||
msg = job
|
||||
else
|
||||
msg += ", [job]"
|
||||
add_note(M.ckey, "Banned from [msg] - [reason]", null, usr.ckey, 0, null, 0)
|
||||
create_message("note", M.ckey, null, "Banned from [msg] - [reason]", null, null, 0, 0)
|
||||
message_admins("<span class='adminnotice'>[key_name_admin(usr)] banned [key_name_admin(M)] from [msg].</span>")
|
||||
M << "<span class='boldannounce'><BIG>You have been [(msg == ("ooc" || "appearance")) ? "banned" : "jobbanned"] by [usr.client.ckey] from: [msg].</BIG></span>"
|
||||
M << "<span class='boldannounce'>The reason is: [reason]</span>"
|
||||
@@ -1010,58 +1010,88 @@
|
||||
//M.client = null
|
||||
qdel(M.client)
|
||||
|
||||
//Player Notes
|
||||
else if(href_list["addmessage"])
|
||||
var/target_ckey = href_list["addmessage"]
|
||||
create_message("message", target_ckey, secret = 0)
|
||||
|
||||
else if(href_list["addnote"])
|
||||
var/target_ckey = href_list["addnote"]
|
||||
add_note(target_ckey)
|
||||
create_message("note", target_ckey)
|
||||
|
||||
else if(href_list["addwatch"])
|
||||
var/target_ckey = href_list["addwatch"]
|
||||
create_message("watchlist entry", target_ckey, secret = 1)
|
||||
|
||||
else if(href_list["addmemo"])
|
||||
create_message("memo", secret = 0, browse = 1)
|
||||
|
||||
else if(href_list["addmessageempty"])
|
||||
create_message("message", secret = 0)
|
||||
|
||||
else if(href_list["addnoteempty"])
|
||||
add_note()
|
||||
create_message("note")
|
||||
|
||||
else if(href_list["removenote"])
|
||||
var/note_id = href_list["removenote"]
|
||||
remove_note(note_id)
|
||||
else if(href_list["addwatchempty"])
|
||||
create_message("watchlist entry", secret = 1)
|
||||
|
||||
else if(href_list["editnote"])
|
||||
var/note_id = href_list["editnote"]
|
||||
edit_note(note_id)
|
||||
else if(href_list["deletemessage"])
|
||||
var/message_id = href_list["deletemessage"]
|
||||
delete_message(message_id)
|
||||
|
||||
else if(href_list["shownote"])
|
||||
var/target = href_list["shownote"]
|
||||
show_note(index = target)
|
||||
else if(href_list["deletemessageempty"])
|
||||
var/message_id = href_list["deletemessageempty"]
|
||||
delete_message(message_id, browse = 1)
|
||||
|
||||
else if(href_list["editmessage"])
|
||||
var/message_id = href_list["editmessage"]
|
||||
edit_message(message_id)
|
||||
|
||||
else if(href_list["editmessageempty"])
|
||||
var/message_id = href_list["editmessageempty"]
|
||||
edit_message(message_id, browse = 1)
|
||||
|
||||
else if(href_list["secretmessage"])
|
||||
var/message_id = href_list["secretmessage"]
|
||||
toggle_message_secrecy(message_id)
|
||||
|
||||
else if(href_list["searchmessages"])
|
||||
var/target = href_list["searchmessages"]
|
||||
browse_messages(index = target)
|
||||
|
||||
else if(href_list["nonalpha"])
|
||||
var/target = href_list["nonalpha"]
|
||||
target = text2num(target)
|
||||
show_note(index = target)
|
||||
browse_messages(index = target)
|
||||
|
||||
else if(href_list["shownoteckey"])
|
||||
var/target_ckey = href_list["shownoteckey"]
|
||||
show_note(target_ckey)
|
||||
else if(href_list["showmessages"])
|
||||
var/target = href_list["showmessages"]
|
||||
browse_messages(index = target)
|
||||
|
||||
else if(href_list["shownoteckeylinkless"])
|
||||
var/target_ckey = href_list["shownoteckeylinkless"]
|
||||
show_note(target_ckey, null, 1)
|
||||
else if(href_list["showmemo"])
|
||||
browse_messages("memo")
|
||||
|
||||
else if(href_list["notessearch"])
|
||||
var/target = href_list["notessearch"]
|
||||
show_note(index = target)
|
||||
else if(href_list["showwatch"])
|
||||
browse_messages("watchlist entry")
|
||||
|
||||
else if(href_list["noteedits"])
|
||||
var/note_id = sanitizeSQL("[href_list["noteedits"]]")
|
||||
var/DBQuery/query_noteedits = dbcon.NewQuery("SELECT edits FROM [format_table_name("notes")] WHERE id = '[note_id]'")
|
||||
if(!query_noteedits.Execute())
|
||||
var/err = query_noteedits.ErrorMsg()
|
||||
log_game("SQL ERROR obtaining edits from notes table. Error : \[[err]\]\n")
|
||||
else if(href_list["showmessageckey"])
|
||||
var/target = href_list["showmessageckey"]
|
||||
browse_messages(target_ckey = target)
|
||||
|
||||
else if(href_list["showmessageckeylinkless"])
|
||||
var/target = href_list["showmessageckeylinkless"]
|
||||
browse_messages(target_ckey = target, linkless = 1)
|
||||
|
||||
else if(href_list["messageedits"])
|
||||
var/message_id = sanitizeSQL("[href_list["messageedits"]]")
|
||||
var/DBQuery/query_get_message_edits = dbcon.NewQuery("SELECT edits FROM [format_table_name("messages")] WHERE id = '[message_id]'")
|
||||
if(!query_get_message_edits.Execute())
|
||||
var/err = query_get_message_edits.ErrorMsg()
|
||||
log_game("SQL ERROR obtaining edits from messages table. Error : \[[err]\]\n")
|
||||
return
|
||||
if(query_noteedits.NextRow())
|
||||
var/edit_log = query_noteedits.item[1]
|
||||
if(query_get_message_edits.NextRow())
|
||||
var/edit_log = query_get_message_edits.item[1]
|
||||
usr << browse(edit_log,"window=noteedits")
|
||||
|
||||
else if(href_list["secretnote"])
|
||||
var/note_id = href_list["secretnote"]
|
||||
toggle_note_secrecy(note_id)
|
||||
|
||||
else if(href_list["newban"])
|
||||
if(!check_rights(R_BAN))
|
||||
return
|
||||
@@ -1126,48 +1156,6 @@
|
||||
if("Cancel")
|
||||
return
|
||||
|
||||
//Watchlist
|
||||
else if(href_list["watchadd"])
|
||||
var/target_ckey = locate(href_list["watchadd"])
|
||||
usr.client.watchlist_add(target_ckey)
|
||||
|
||||
else if(href_list["watchremove"])
|
||||
var/target_ckey = href_list["watchremove"]
|
||||
usr.client.watchlist_remove(target_ckey)
|
||||
|
||||
else if(href_list["watchedit"])
|
||||
var/target_ckey = href_list["watchedit"]
|
||||
usr.client.watchlist_edit(target_ckey)
|
||||
|
||||
else if(href_list["watchaddbrowse"])
|
||||
usr.client.watchlist_add(null, 1)
|
||||
|
||||
else if(href_list["watchremovebrowse"])
|
||||
var/target_ckey = href_list["watchremovebrowse"]
|
||||
usr.client.watchlist_remove(target_ckey, 1)
|
||||
|
||||
else if(href_list["watcheditbrowse"])
|
||||
var/target_ckey = href_list["watcheditbrowse"]
|
||||
usr.client.watchlist_edit(target_ckey, 1)
|
||||
|
||||
else if(href_list["watchsearch"])
|
||||
var/target_ckey = href_list["watchsearch"]
|
||||
usr.client.watchlist_show(target_ckey)
|
||||
|
||||
else if(href_list["watchshow"])
|
||||
usr.client.watchlist_show()
|
||||
|
||||
else if(href_list["watcheditlog"])
|
||||
var/target_ckey = sanitizeSQL("[href_list["watcheditlog"]]")
|
||||
var/DBQuery/query_watchedits = dbcon.NewQuery("SELECT edits FROM [format_table_name("watch")] WHERE ckey = '[target_ckey]'")
|
||||
if(!query_watchedits.Execute())
|
||||
var/err = query_watchedits.ErrorMsg()
|
||||
log_game("SQL ERROR obtaining edits from watch table. Error : \[[err]\]\n")
|
||||
return
|
||||
if(query_watchedits.NextRow())
|
||||
var/edit_log = query_watchedits.item[1]
|
||||
usr << browse(edit_log,"window=watchedits")
|
||||
|
||||
else if(href_list["mute"])
|
||||
if(!check_rights(R_ADMIN))
|
||||
return
|
||||
@@ -2132,17 +2120,6 @@
|
||||
FM.locked ^= 1
|
||||
src.access_news_network()
|
||||
|
||||
else if(href_list["memoeditlist"])
|
||||
var/sql_key = sanitizeSQL("[href_list["memoeditlist"]]")
|
||||
var/DBQuery/query_memoedits = dbcon.NewQuery("SELECT edits FROM [format_table_name("memo")] WHERE (ckey = '[sql_key]')")
|
||||
if(!query_memoedits.Execute())
|
||||
var/err = query_memoedits.ErrorMsg()
|
||||
log_game("SQL ERROR obtaining edits from memo table. Error : \[[err]\]\n")
|
||||
return
|
||||
if(query_memoedits.NextRow())
|
||||
var/edit_log = query_memoedits.item[1]
|
||||
usr << browse(edit_log,"window=memoeditlist")
|
||||
|
||||
else if(href_list["check_antagonist"])
|
||||
if(!check_rights(R_ADMIN))
|
||||
return
|
||||
|
||||
@@ -1,119 +0,0 @@
|
||||
/client/proc/watchlist_add(target_ckey, browse = 0)
|
||||
if(!target_ckey)
|
||||
var/new_ckey = ckey(input(usr,"Who would you like to add to the watchlist?","Enter a ckey",null) as text)
|
||||
if(!new_ckey)
|
||||
return
|
||||
new_ckey = sanitizeSQL(new_ckey)
|
||||
var/DBQuery/query_watchfind = dbcon.NewQuery("SELECT ckey FROM [format_table_name("player")] WHERE ckey = '[new_ckey]'")
|
||||
if(!query_watchfind.Execute())
|
||||
var/err = query_watchfind.ErrorMsg()
|
||||
log_game("SQL ERROR obtaining ckey from player table. Error : \[[err]\]\n")
|
||||
return
|
||||
if(!query_watchfind.NextRow())
|
||||
if(alert(usr, "[new_ckey] has not been seen before, are you sure you want to add them to the watchlist?", "Unknown ckey", "Yes", "No", "Cancel") != "Yes")
|
||||
return
|
||||
target_ckey = new_ckey
|
||||
var/target_sql_ckey = sanitizeSQL(target_ckey)
|
||||
if(check_watchlist(target_sql_ckey))
|
||||
usr << "<span class='redtext'>[target_sql_ckey] is already on the watchlist.</span>"
|
||||
return
|
||||
var/reason = input(usr,"Please State Reason","Reason") as message
|
||||
if(!reason)
|
||||
return
|
||||
reason = sanitizeSQL(reason)
|
||||
var/timestamp = SQLtime()
|
||||
var/adminckey = usr.ckey
|
||||
if(!adminckey)
|
||||
return
|
||||
var/admin_sql_ckey = sanitizeSQL(adminckey)
|
||||
var/DBQuery/query_watchadd = dbcon.NewQuery("INSERT INTO [format_table_name("watch")] (ckey, reason, adminckey, timestamp) VALUES ('[target_sql_ckey]', '[reason]', '[admin_sql_ckey]', '[timestamp]')")
|
||||
if(!query_watchadd.Execute())
|
||||
var/err = query_watchadd.ErrorMsg()
|
||||
log_game("SQL ERROR during adding new watch entry. Error : \[[err]\]\n")
|
||||
return
|
||||
log_admin("[key_name(usr)] has added [target_ckey] to the watchlist - Reason: [reason]")
|
||||
message_admins("[key_name_admin(usr)] has added [target_ckey] to the watchlist - Reason: [reason]", 1)
|
||||
if(browse)
|
||||
watchlist_show(target_sql_ckey)
|
||||
|
||||
add_note(target_ckey, "Added to Watchlist - [reason]", null, usr.ckey, 0, null, 1)
|
||||
|
||||
/client/proc/watchlist_remove(target_ckey, browse = 0)
|
||||
var/target_sql_ckey = sanitizeSQL(target_ckey)
|
||||
var/DBQuery/query_watchdel = dbcon.NewQuery("DELETE FROM [format_table_name("watch")] WHERE ckey = '[target_sql_ckey]'")
|
||||
if(!query_watchdel.Execute())
|
||||
var/err = query_watchdel.ErrorMsg()
|
||||
log_game("SQL ERROR during removing watch entry. Error : \[[err]\]\n")
|
||||
return
|
||||
log_admin("[key_name(usr)] has removed [target_ckey] from the watchlist")
|
||||
message_admins("[key_name_admin(usr)] has removed [target_ckey] from the watchlist", 1)
|
||||
if(browse)
|
||||
watchlist_show()
|
||||
|
||||
/client/proc/watchlist_edit(target_ckey, browse = 0)
|
||||
var/target_sql_ckey = sanitizeSQL(target_ckey)
|
||||
var/DBQuery/query_watchreason = dbcon.NewQuery("SELECT reason FROM [format_table_name("watch")] WHERE ckey = '[target_sql_ckey]'")
|
||||
if(!query_watchreason.Execute())
|
||||
var/err = query_watchreason.ErrorMsg()
|
||||
log_game("SQL ERROR obtaining reason from watch table. Error : \[[err]\]\n")
|
||||
return
|
||||
if(query_watchreason.NextRow())
|
||||
var/watch_reason = query_watchreason.item[1]
|
||||
var/new_reason = input("Input new reason", "New Reason", "[watch_reason]") as message
|
||||
new_reason = sanitizeSQL(new_reason)
|
||||
if(!new_reason)
|
||||
return
|
||||
var/sql_ckey = sanitizeSQL(usr.ckey)
|
||||
var/edit_text = "Edited by [sql_ckey] on [SQLtime()] from<br>[watch_reason]<br>to<br>[new_reason]<hr>"
|
||||
edit_text = sanitizeSQL(edit_text)
|
||||
var/DBQuery/query_watchupdate = dbcon.NewQuery("UPDATE [format_table_name("watch")] SET reason = '[new_reason]', last_editor = '[sql_ckey]', edits = CONCAT(IFNULL(edits,''),'[edit_text]') WHERE ckey = '[target_sql_ckey]'")
|
||||
if(!query_watchupdate.Execute())
|
||||
var/err = query_watchupdate.ErrorMsg()
|
||||
log_game("SQL ERROR editing watchlist reason. Error : \[[err]\]\n")
|
||||
return
|
||||
log_admin("[key_name(usr)] has edited [target_ckey]'s watchlist reason from [watch_reason] to [new_reason]")
|
||||
message_admins("[key_name_admin(usr)] has edited [target_ckey]'s watchlist reason from<br>[watch_reason]<br>to<br>[new_reason]")
|
||||
if(browse)
|
||||
watchlist_show(target_sql_ckey)
|
||||
|
||||
/client/proc/watchlist_show(search)
|
||||
var/output
|
||||
output += "<form method='GET' name='search' action='?'>\
|
||||
<input type='hidden' name='_src_' value='holder'>\
|
||||
<input type='text' name='watchsearch' value='[search]'>\
|
||||
<input type='submit' value='Search'></form>"
|
||||
output += "<a href='?_src_=holder;watchshow=1'>\[Clear Search\]</a> <a href='?_src_=holder;watchaddbrowse=1'>\[Add Ckey\]</a>"
|
||||
output += "<hr style='background:#000000; border:0; height:3px'>"
|
||||
if(search)
|
||||
search = "^[search]"
|
||||
else
|
||||
search = "^."
|
||||
search = sanitizeSQL(search)
|
||||
var/DBQuery/query_watchlist = dbcon.NewQuery("SELECT ckey, reason, adminckey, timestamp, last_editor FROM [format_table_name("watch")] WHERE ckey REGEXP '[search]' ORDER BY ckey")
|
||||
if(!query_watchlist.Execute())
|
||||
var/err = query_watchlist.ErrorMsg()
|
||||
log_game("SQL ERROR obtaining ckey, reason, adminckey, timestamp, last_editor from watch table. Error : \[[err]\]\n")
|
||||
return
|
||||
while(query_watchlist.NextRow())
|
||||
var/ckey = query_watchlist.item[1]
|
||||
var/reason = query_watchlist.item[2]
|
||||
var/adminckey = query_watchlist.item[3]
|
||||
var/timestamp = query_watchlist.item[4]
|
||||
var/last_editor = query_watchlist.item[5]
|
||||
output += "<b>[ckey]</b> | Added by <b>[adminckey]</b> on <b>[timestamp]</b> <a href='?_src_=holder;watchremovebrowse=[ckey]'>\[Remove\]</a> <a href='?_src_=holder;watcheditbrowse=[ckey]'>\[Edit Reason\]</a>"
|
||||
if(last_editor)
|
||||
output += " <font size='2'>Last edit by [last_editor] <a href='?_src_=holder;watcheditlog=[ckey]'>(Click here to see edit log)</a></font>"
|
||||
output += "<br>[reason]<hr style='background:#000000; border:0; height:1px'>"
|
||||
usr << browse(output, "window=watchwin;size=900x500")
|
||||
|
||||
/client/proc/check_watchlist(target_ckey)
|
||||
var/target_sql_ckey = sanitizeSQL(target_ckey)
|
||||
var/DBQuery/query_watch = dbcon.NewQuery("SELECT reason FROM [format_table_name("watch")] WHERE ckey = '[target_sql_ckey]'")
|
||||
if(!query_watch.Execute())
|
||||
var/err = query_watch.ErrorMsg()
|
||||
log_game("SQL ERROR obtaining reason from watch table. Error : \[[err]\]\n")
|
||||
return
|
||||
if(query_watch.NextRow())
|
||||
return query_watch.item[1]
|
||||
else
|
||||
return 0
|
||||
@@ -234,7 +234,7 @@ var/next_external_rsc = 0
|
||||
|
||||
if(holder)
|
||||
add_admin_verbs()
|
||||
admin_memo_output("Show")
|
||||
src << get_message_output("memo")
|
||||
adminGreet()
|
||||
if((global.comms_key == "default_pwd" || length(global.comms_key) <= 6) && global.comms_allowed) //It's the default value or less than 6 characters long, but it somehow didn't disable comms.
|
||||
src << "<span class='danger'>The server's API key is either too short or is the default value! Consider changing it immediately!</span>"
|
||||
@@ -268,7 +268,7 @@ var/next_external_rsc = 0
|
||||
findJoinDate()
|
||||
|
||||
sync_client_with_db(tdata)
|
||||
|
||||
get_message_output("watchlist entry", ckey)
|
||||
check_ip_intel()
|
||||
|
||||
send_resources()
|
||||
@@ -292,7 +292,7 @@ var/next_external_rsc = 0
|
||||
|
||||
if(config && config.autoconvert_notes)
|
||||
convert_notes_sql(ckey)
|
||||
|
||||
src << get_message_output("message", ckey)
|
||||
if(!winexists(src, "asset_cache_browser")) // The client is using a custom skin, tell them.
|
||||
src << "<span class='warning'>Unable to access asset cache browser, if you are using a custom skin file, please allow DS to download the updated version, if you are not, then make a bug report. This is not a critical issue but can cause issues with resource downloading, as it is impossible to know when extra resources arrived to you.</span>"
|
||||
|
||||
@@ -372,12 +372,6 @@ var/next_external_rsc = 0
|
||||
if (check_randomizer(connectiontopic))
|
||||
return
|
||||
|
||||
var/watchreason = check_watchlist(sql_ckey)
|
||||
if(watchreason)
|
||||
current_watchlist[sql_ckey] = watchreason
|
||||
message_admins("<font color='red'><B>Notice: </B></font><font color='blue'>[key_name_admin(src)] is on the watchlist and has just connected - Reason: [watchreason]</font>")
|
||||
send2irc_adminless_only("Watchlist", "[key_name(src)] is on the watchlist and has just connected - Reason: [watchreason]")
|
||||
|
||||
var/sql_ip = sanitizeSQL(src.address)
|
||||
var/sql_computerid = sanitizeSQL(src.computer_id)
|
||||
var/sql_admin_rank = sanitizeSQL(admin_rank)
|
||||
@@ -472,24 +466,24 @@ var/next_external_rsc = 0
|
||||
var/const/adminckey = "CID-Error"
|
||||
var/sql_ckey = sanitizeSQL(ckey)
|
||||
//check to see if we noted them in the last day.
|
||||
var/DBQuery/query_get_notes = dbcon.NewQuery("SELECT id FROM [format_table_name("notes")] WHERE ckey = '[sql_ckey]' AND adminckey = '[adminckey]' AND timestamp + INTERVAL 1 DAY < NOW()")
|
||||
var/DBQuery/query_get_notes = dbcon.NewQuery("SELECT id FROM [format_table_name("messages")] WHERE type = 'note' AND targetckey = '[sql_ckey]' AND adminckey = '[adminckey]' AND timestamp + INTERVAL 1 DAY < NOW()")
|
||||
if(!query_get_notes.Execute())
|
||||
var/err = query_get_notes.ErrorMsg()
|
||||
log_game("SQL ERROR obtaining id from notes table. Error : \[[err]\]\n")
|
||||
log_game("SQL ERROR obtaining id from messages table. Error : \[[err]\]\n")
|
||||
return
|
||||
if (query_get_notes.NextRow())
|
||||
return
|
||||
|
||||
//regardless of above, make sure their last note is not from us, as no point in repeating the same note over and over.
|
||||
query_get_notes = dbcon.NewQuery("SELECT adminckey FROM [format_table_name("notes")] WHERE ckey = '[sql_ckey]' ORDER BY timestamp DESC LIMIT 1")
|
||||
query_get_notes = dbcon.NewQuery("SELECT adminckey FROM [format_table_name("messages")] WHERE targetckey = '[sql_ckey]' ORDER BY timestamp DESC LIMIT 1")
|
||||
if(!query_get_notes.Execute())
|
||||
var/err = query_get_notes.ErrorMsg()
|
||||
log_game("SQL ERROR obtaining id from notes table. Error : \[[err]\]\n")
|
||||
log_game("SQL ERROR obtaining adminckey from notes table. Error : \[[err]\]\n")
|
||||
return
|
||||
if (query_get_notes.NextRow())
|
||||
if (query_get_notes.item[1] == adminckey)
|
||||
return
|
||||
add_note(ckey, "Detected as using a cid randomizer.", null, adminckey, 0, null, 0)
|
||||
create_message("note", sql_ckey, adminckey, "Detected as using a cid randomizer.", null, null, 0, 0)
|
||||
|
||||
|
||||
/client/proc/check_ip_intel()
|
||||
|
||||
@@ -152,7 +152,7 @@ var/global/normal_ooc_colour = OOC_COLOR
|
||||
usr << "<span class='notice'>Sorry, that function is not enabled on this server.</span>"
|
||||
return
|
||||
|
||||
show_note(usr.ckey, null, 1)
|
||||
browse_messages(null, usr.ckey, null, 1)
|
||||
|
||||
/client/proc/ignore_key(client)
|
||||
var/client/C = client
|
||||
|
||||
@@ -933,7 +933,6 @@
|
||||
#include "code\js\menus.dm"
|
||||
#include "code\modules\admin\admin.dm"
|
||||
#include "code\modules\admin\admin_investigate.dm"
|
||||
#include "code\modules\admin\admin_memo.dm"
|
||||
#include "code\modules\admin\admin_ranks.dm"
|
||||
#include "code\modules\admin\admin_verbs.dm"
|
||||
#include "code\modules\admin\banjob.dm"
|
||||
@@ -948,10 +947,9 @@
|
||||
#include "code\modules\admin\NewBan.dm"
|
||||
#include "code\modules\admin\player_panel.dm"
|
||||
#include "code\modules\admin\secrets.dm"
|
||||
#include "code\modules\admin\sql_notes.dm"
|
||||
#include "code\modules\admin\sql_message_system.dm"
|
||||
#include "code\modules\admin\stickyban.dm"
|
||||
#include "code\modules\admin\topic.dm"
|
||||
#include "code\modules\admin\watchlist.dm"
|
||||
#include "code\modules\admin\whitelist.dm"
|
||||
#include "code\modules\admin\DB_ban\functions.dm"
|
||||
#include "code\modules\admin\permissionverbs\permissionedit.dm"
|
||||
|
||||
Reference in New Issue
Block a user