mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-26 13:37:58 +01:00
SQL update
This commit is contained in:
@@ -43,8 +43,7 @@ datum/borrowbook // Datum used to keep track of who has borrowed what when and f
|
||||
<A href='?src=\ref[src];setauthor=1'>Filter by Author: [author]</A><BR>
|
||||
<A href='?src=\ref[src];search=1'>\[Start Search\]</A><BR>"}
|
||||
if(1)
|
||||
establish_old_db_connection()
|
||||
if(!dbcon_old.IsConnected())
|
||||
if(!dbcon.IsConnected())
|
||||
dat += "<font color=red><b>ERROR</b>: Unable to contact External Archive. Please contact your system administrator for assistance.</font><BR>"
|
||||
else if(!SQLquery)
|
||||
dat += "<font color=red><b>ERROR</b>: Malformed search request. Please contact your system administrator for assistance.</font><BR>"
|
||||
@@ -52,7 +51,7 @@ datum/borrowbook // Datum used to keep track of who has borrowed what when and f
|
||||
dat += "<table>"
|
||||
dat += "<tr><td>AUTHOR</td><td>TITLE</td><td>CATEGORY</td><td>SS<sup>13</sup>BN</td></tr>"
|
||||
|
||||
var/DBQuery/query = dbcon_old.NewQuery(SQLquery)
|
||||
var/DBQuery/query = dbcon.NewQuery(SQLquery)
|
||||
query.Execute()
|
||||
|
||||
while(query.NextRow())
|
||||
@@ -94,7 +93,7 @@ datum/borrowbook // Datum used to keep track of who has borrowed what when and f
|
||||
author = null
|
||||
author = sanitizeSQL(author)
|
||||
if(href_list["search"])
|
||||
SQLquery = "SELECT author, title, category, id FROM library WHERE "
|
||||
SQLquery = "SELECT author, title, category, id FROM [format_table_name("library")] WHERE "
|
||||
if(category == "Any")
|
||||
SQLquery += "author LIKE '%[author]%' AND title LIKE '%[title]%'"
|
||||
else
|
||||
@@ -189,16 +188,18 @@ datum/borrowbook // Datum used to keep track of who has borrowed what when and f
|
||||
<A href='?src=\ref[src];switchscreen=0'>(Return to main menu)</A><BR>"}
|
||||
if(4)
|
||||
dat += "<h3>External Archive</h3>"
|
||||
establish_old_db_connection()
|
||||
if(!dbcon_old.IsConnected())
|
||||
if(!dbcon.IsConnected())
|
||||
dat += "<font color=red><b>ERROR</b>: Unable to contact External Archive. Please contact your system administrator for assistance.</font>"
|
||||
else
|
||||
dat += "<A href='?src=\ref[src];orderbyid=1'>(Order book by SS<sup>13</sup>BN)</A><BR><BR>"
|
||||
dat += "<table>"
|
||||
dat += "<tr><td>AUTHOR</td><td>TITLE</td><td>CATEGORY</td><td>ID</td><td></td></tr>"
|
||||
|
||||
var/DBQuery/query = dbcon_old.NewQuery("SELECT id, author, title, category FROM library")
|
||||
query.Execute()
|
||||
var/DBQuery/query = dbcon.NewQuery("SELECT id, author, title, category FROM [format_table_name("library")]")
|
||||
if(!query.Execute())
|
||||
var/err = query.ErrorMsg()
|
||||
log_game("SQL ERROR accessing book. Error : \[[err]\]\n")
|
||||
return
|
||||
|
||||
while(query.NextRow())
|
||||
var/id = query.item[1]
|
||||
@@ -333,8 +334,7 @@ datum/borrowbook // Datum used to keep track of who has borrowed what when and f
|
||||
if(scanner.cache)
|
||||
var/choice = input("Are you certain you wish to upload this title to the Archive?") in list("Confirm", "Abort")
|
||||
if(choice == "Confirm")
|
||||
establish_old_db_connection()
|
||||
if(!dbcon_old.IsConnected())
|
||||
if(!dbcon.IsConnected())
|
||||
alert("Connection to Archive has been severed. Aborting.")
|
||||
else
|
||||
/*
|
||||
@@ -347,9 +347,11 @@ datum/borrowbook // Datum used to keep track of who has borrowed what when and f
|
||||
var/sqlauthor = sanitizeSQL(scanner.cache.author)
|
||||
var/sqlcontent = sanitizeSQL(scanner.cache.dat)
|
||||
var/sqlcategory = sanitizeSQL(upload_category)
|
||||
var/DBQuery/query = dbcon_old.NewQuery("INSERT INTO library (author, title, content, category, ckey) VALUES ('[sqlauthor]', '[sqltitle]', '[sqlcontent]', '[sqlcategory]', '[usr.key]')")
|
||||
var/DBQuery/query = dbcon.NewQuery("INSERT INTO [format_table_name("library")] (author, title, content, category, ckey) VALUES ('[sqlauthor]', '[sqltitle]', '[sqlcontent]', '[sqlcategory]', '[usr.key]')")
|
||||
if(!query.Execute())
|
||||
usr << query.ErrorMsg()
|
||||
var/err = query.ErrorMsg()
|
||||
log_game("SQL ERROR adding new book. Error : \[[err]\]\n")
|
||||
return
|
||||
else
|
||||
log_game("[usr.name]/[usr.key] has uploaded the book titled [scanner.cache.name], [length(scanner.cache.dat)] signs")
|
||||
message_admins("[key_name_admin(usr)] has uploaded the book titled [scanner.cache.name], [length(scanner.cache.dat)] signs")
|
||||
@@ -357,8 +359,7 @@ datum/borrowbook // Datum used to keep track of who has borrowed what when and f
|
||||
|
||||
if(href_list["targetid"])
|
||||
var/sqlid = sanitizeSQL(href_list["targetid"])
|
||||
establish_old_db_connection()
|
||||
if(!dbcon_old.IsConnected())
|
||||
if(!dbcon.IsConnected())
|
||||
alert("Connection to Archive has been severed. Aborting.")
|
||||
|
||||
// reused working printing call from bible code.. needs testing ((Lazureus))
|
||||
@@ -367,7 +368,7 @@ datum/borrowbook // Datum used to keep track of who has borrowed what when and f
|
||||
bibledelay = 1
|
||||
spawn(60)
|
||||
bibledelay = 0
|
||||
var/DBQuery/query = dbcon_old.NewQuery("SELECT * FROM library WHERE id=[sqlid]")
|
||||
var/DBQuery/query = dbcon.NewQuery("SELECT * FROM [format_table_name("library")] WHERE id=[sqlid]")
|
||||
query.Execute()
|
||||
|
||||
while(query.NextRow())
|
||||
@@ -472,6 +473,7 @@ datum/borrowbook // Datum used to keep track of who has borrowed what when and f
|
||||
qdel(O)
|
||||
else
|
||||
..()
|
||||
|
||||
/client/proc/delbook()
|
||||
set name = "Delete Book"
|
||||
set desc = "Permamently deletes a book from the database."
|
||||
@@ -483,15 +485,12 @@ datum/borrowbook // Datum used to keep track of who has borrowed what when and f
|
||||
var/isbn = input("ISBN number?", "Delete Book") as num | null
|
||||
if(!isbn)
|
||||
return
|
||||
|
||||
var/DBQuery/query_delbook = dbcon.NewQuery("DELETE FROM [format_table_name("library")] WHERE id=[isbn]")
|
||||
if(!query_delbook.Execute())
|
||||
var/err = query_delbook.ErrorMsg()
|
||||
log_game("SQL ERROR deleting book. Error : \[[err]\]\n")
|
||||
return
|
||||
|
||||
if(dbcon_old.IsConnected())
|
||||
var/DBConnection/dbcon = new()
|
||||
dbcon.Connect("dbi:mysql:[sqldb]:[sqladdress]:[sqlport]","[sqllogin]","[sqlpass]")
|
||||
if(!dbcon.IsConnected())
|
||||
alert("Connection to Archive has been severed. Aborting.")
|
||||
else
|
||||
var/DBQuery/query = dbcon.NewQuery("DELETE FROM library WHERE id=[isbn]")
|
||||
if(!query.Execute())
|
||||
usr << query.ErrorMsg()
|
||||
dbcon.Disconnect()
|
||||
log_admin("[usr.key] has deleted the book [isbn]")
|
||||
log_admin("[key_name(usr)] has deleted the book [isbn].")
|
||||
message_admins("[key_name_admin(usr) has deleted the book [isbn].")
|
||||
|
||||
Reference in New Issue
Block a user