Changed source to include time - ultimateplayer1999

This commit is contained in:
ultimateplayer1999 2023-01-10 11:23:10 +01:00
parent 0ee5472332
commit 639ff3ceb7
Signed by: ultimateplayer1999
GPG Key ID: 690D4E43F8B51E51
2 changed files with 29 additions and 4 deletions

View File

@ -8,6 +8,7 @@ import (
"net/http"
"io/ioutil"
"encoding/json"
"time"
"github.com/joho/godotenv"
@ -33,6 +34,13 @@ func main() {
log.Fatal(err)
}
// Get the start time
StartTime := time.Now()
// Format the start time
formattedStartTime := StartTime.Format("10-01-2023 10:22:10")
fmt.Println("Script started at " + formattedStartTime)
// Perform a cleanup on DB
deleter, err := db.Exec("DELETE FROM phish;")
if err != nil {
@ -43,7 +51,7 @@ func main() {
if err != nil {
log.Fatal(err)
}
fmt.Printf("Number of rows affected: %d\n", rowsAffected)
fmt.Printf("Deletion: Number of rows affected: %d\n", rowsAffected)
// Perform a cleanup on DB
aiupdate, err := db.Exec("ALTER TABLE phish AUTO_INCREMENT = 0;")
@ -55,7 +63,7 @@ func main() {
if err != nil {
log.Fatal(err)
}
fmt.Printf("Number of rows affected: %d\n", rowsAffected)
fmt.Printf("Altering: Number of rows affected: %d\n", rowsAffected)
// Add local records first
insert1, err := db.Exec("INSERT INTO phish (Domain, Reporter, Evidence) VALUES ('iriseperiplo.info', 'Henk', 'https://www.virustotal.com/gui/url/318ac29af0001f6678efdd94c16d3225d78369123ebbbe5f50387b208e0ac523?nocache=1');")
@ -71,13 +79,13 @@ func main() {
if err != nil {
log.Fatal(err)
}
fmt.Printf("Number of rows affected: %d\n", rowsAffected)
fmt.Printf("Insert: Number of rows affected: %d\n", rowsAffected)
// Get the number of affected rows
rowsAffected, err = insert2.RowsAffected()
if err != nil {
log.Fatal(err)
}
fmt.Printf("Number of rows affected: %d\n", rowsAffected)
fmt.Printf("Insert: Number of rows affected: %d\n", rowsAffected)
// Define name for use later
// name := os.Getenv("USER_OR_BOTNAME")
@ -125,6 +133,23 @@ func main() {
totalRowsAffected += rowsAffected
}
fmt.Printf("Total number of rows affected: %d\n", totalRowsAffected)
// Get the end time
EndTime := time.Now()
// Format the end time
formattedEndTime := EndTime.Format("10-01-2023 10:22:50")
fmt.Println("Recent changes recieved and has been added to the database. Removed domains deleted from database. Reorded domains.")
fmt.Println("Script ended at " + formattedEndTime)
// Calculate the time difference
diff := formattedEndTime.sub(formattedStartTime)
// Print the time difference
fmt.Println("Time until completion: ", diff)
// dummy
// fmt.Println("Data: ", string(body))
}

Binary file not shown.