diff --git a/inc/database/flatfile.php b/inc/database/flatfile.php index 12b89b2..c06ad0b 100644 --- a/inc/database/flatfile.php +++ b/inc/database/flatfile.php @@ -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) { diff --git a/inc/database/mysql.php b/inc/database/mysql.php index 8802265..993c37c 100644 --- a/inc/database/mysql.php +++ b/inc/database/mysql.php @@ -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']) . "')"); } diff --git a/inc/database/mysqli.php b/inc/database/mysqli.php index 124ecb3..f1b914c 100644 --- a/inc/database/mysqli.php +++ b/inc/database/mysqli.php @@ -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']) . "')"); diff --git a/inc/database/pdo.php b/inc/database/pdo.php index 7e6ed80..41fdf9f 100644 --- a/inc/database/pdo.php +++ b/inc/database/pdo.php @@ -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 (?, ?, ?)"); diff --git a/inc/database/sqlite.php b/inc/database/sqlite.php index 182249d..8c3eab9 100644 --- a/inc/database/sqlite.php +++ b/inc/database/sqlite.php @@ -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']) . "')"); } diff --git a/inc/database/sqlite3.php b/inc/database/sqlite3.php index 6ae49fe..3536518 100644 --- a/inc/database/sqlite3.php +++ b/inc/database/sqlite3.php @@ -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']) . "')"); diff --git a/inc/database/sqlite3_link.php b/inc/database/sqlite3_link.php index 7fac5c7..df706c3 100644 --- a/inc/database/sqlite3_link.php +++ b/inc/database/sqlite3_link.php @@ -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) {