Add missing addLogs function

This function is required when migrating between databases.
This commit is contained in:
Trevor Slocum 2023-03-19 19:18:17 -07:00
parent 57704531cf
commit 7c6cf64d4d
7 changed files with 57 additions and 1 deletions

View File

@ -184,6 +184,11 @@ function getLogs($offset, $limit) {
return convertLogsToSQLStyle($rows);
}
function allLogs() {
$rows = $GLOBALS['db']->selectWhere(LOGS_FILE, NULL, -1, new OrderBy(LOG_TIMESTAMP, ASCENDING, INTEGER_COMPARISON));
return convertLogsToSQLStyle($rows);
}
function convertLogsToSQLStyle($logs, $single = false) {
$newlogs = array();
foreach ($logs as $l) {

View File

@ -147,6 +147,17 @@ function getLogs($offset, $limit) {
return $logs;
}
function allLogs() {
$logs = array();
$result = mysql_query("SELECT * FROM `" . TINYIB_DBLOGS . "` ORDER BY `timestamp` ASC");
if ($result) {
while ($log = mysql_fetch_assoc($result)) {
$logs[] = $log;
}
}
return $logs;
}
function insertLog($log) {
mysql_query("INSERT INTO `" . TINYIB_DBLOGS . "` (`timestamp`, `account`, `message`) VALUES ('" . mysql_real_escape_string($log['timestamp']) . "', '" . mysql_real_escape_string($log['account']) . "', '" . mysql_real_escape_string($log['message']) . "')");
}

View File

@ -168,6 +168,18 @@ function getLogs($offset, $limit) {
return $logs;
}
function allLogs() {
global $link;
$logs = array();
$result = mysqli_query($link, "SELECT * FROM `" . TINYIB_DBLOGS . "` ORDER BY `timestamp` ASC");
if ($result) {
while ($log = mysqli_fetch_assoc($result)) {
$logs[] = $log;
}
}
return $logs;
}
function insertLog($log) {
global $link;
mysqli_query($link, "INSERT INTO `" . TINYIB_DBLOGS . "` (`timestamp`, `account`, `message`) VALUES ('" . mysqli_real_escape_string($link, $log['timestamp']) . "', '" . mysqli_real_escape_string($link, $log['account']) . "', '" . mysqli_real_escape_string($link, $log['message']) . "')");

View File

@ -124,6 +124,15 @@ function getLogs($offset, $limit) {
return $logs;
}
function allLogs() {
$logs = array();
$results = pdoQuery("SELECT * FROM " . TINYIB_DBLOGS . " ORDER BY timestamp ASC");
while ($row = $results->fetch(PDO::FETCH_ASSOC)) {
$logs[] = $row;
}
return $logs;
}
function insertLog($log) {
global $dbh;
$stm = $dbh->prepare("INSERT INTO " . TINYIB_DBLOGS . " (timestamp, account, message) VALUES (?, ?, ?)");

View File

@ -128,6 +128,15 @@ function getLogs($offset, $limit) {
return $logs;
}
function allLogs() {
$logs = array();
$result = sqlite_fetch_all(sqlite_query($GLOBALS["db"], "SELECT * FROM " . TINYIB_DBLOGS . " ORDER BY timestamp ASC"), SQLITE_ASSOC);
foreach ($result as $log) {
$logs[] = $log;
}
return $logs;
}
function insertLog($log) {
sqlite_query($GLOBALS["db"], "INSERT INTO " . TINYIB_DBLOGS . " (timestamp, account, message) VALUES ('" . sqlite_escape_string($log['timestamp']) . "', '" . sqlite_escape_string($log['account']) . "', '" . sqlite_escape_string($log['message']) . "')");
}

View File

@ -147,6 +147,16 @@ function getLogs($offset, $limit) {
return $logs;
}
function allLogs() {
global $db;
$logs = array();
$result = $db->query("SELECT * FROM " . TINYIB_DBLOGS . " ORDER BY timestamp ASC");
while ($log = $result->fetchArray()) {
$logs[] = $log;
}
return $logs;
}
function insertLog($log) {
global $db;
$db->exec("INSERT INTO " . TINYIB_DBLOGS . " (timestamp, account, message) VALUES ('" . $db->escapeString($log['timestamp']) . "', '" . $db->escapeString($log['account']) . "', '" . $db->escapeString($log['message']) . "')");

View File

@ -108,7 +108,7 @@ if (!$result->fetchArray()) {
if (function_exists('insertPost')) {
function migrateAccount($account) {
global $db;
$db->exec("INSERT INTO " . TINYIB_DBACCOUNTS . " (id, username, password, role, lastactive) VALUES (" . $db->escapeString($account['id']) . ", '" . $db->escapeString($account['username']) . "', " . $db->escapeString($account['password']) . ", " . $db->escapeString($account['role']) . ", '" . $db->escapeString($account['lastactive']) . "')");
$db->exec("INSERT INTO " . TINYIB_DBACCOUNTS . " (id, username, password, role, lastactive) VALUES (" . $db->escapeString($account['id']) . ", '" . $db->escapeString($account['username']) . "', '" . $db->escapeString($account['password']) . "', " . $db->escapeString($account['role']) . ", '" . $db->escapeString($account['lastactive']) . "')");
}
function migrateBan($ban) {