From: garvinhicking Date: Tue, 10 Apr 2007 13:23:34 +0000 (+0000) Subject: * Patch #1697590: Proper directory name of SQLite DB-error messages, X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=ac952136fc7165ced6e35f5861d10ebb2121a97b;p=s9y.git * Patch #1697590: Proper directory name of SQLite DB-error messages, thanks to Thijs Kinkhorst --- diff --git a/docs/NEWS b/docs/NEWS index 33ab218..ee0cd8f 100644 --- a/docs/NEWS +++ b/docs/NEWS @@ -3,6 +3,9 @@ Version 1.2 () ------------------------------------------------------------------------ + * Patch #1697590: Proper directory name of SQLite DB-error messages, + thanks to Thijs Kinkhorst + * Enabled setting cache-control headers by default. * Fix wrong next/previous page links when using wrapper.php indexFile diff --git a/include/db/sqlite.inc.php b/include/db/sqlite.inc.php index ab04339..827ca58 100644 --- a/include/db/sqlite.inc.php +++ b/include/db/sqlite.inc.php @@ -56,6 +56,9 @@ function serendipity_db_connect() return $serendipity['dbConn']; } +function serendipity_db_reconnect() { +} + /** * Returns a escaped string, so that it can be safely included in a SQL string encapsulated within quotes, without allowing SQL injection. * @@ -173,11 +176,11 @@ function serendipity_db_in_sql($col, &$search_ids, $type = ' OR ') { if (!is_array($search_ids)) { return false; } - + foreach($search_ids AS $id) { $sql[] = $col . ' = ' . $id; } - + $cond = '(' . implode($type, $sql) . ')'; return $cond; } @@ -221,7 +224,7 @@ function &serendipity_db_query($sql, $single = false, $result_type = "both", $re fwrite($fp, '[' . date('d.m.Y H:i') . '] SQLITE QUERY: ' . $sql . "\n\n"); fclose($fp); } - + if ($reportErr && !$expectError) { $res = sqlite_query($sql, $serendipity['dbConn']); } else { @@ -257,9 +260,13 @@ function &serendipity_db_query($sql, $single = false, $result_type = "both", $re $rows = array(); while (($row = serendipity_db_sqlite_fetch_array($res, $type_map[$result_type]))) { - if (!empty($assocKey) && !empty($assocVal)) { + if (!empty($assocKey)) { // You can fetch a key-associated array via the two function parameters assocKey and assocVal - $rows[$row[$assocKey]] = $row[$assocVal]; + if (empty($assocVal)) { + $rows[$row[$assocKey]] = $row; + } else { + $rows[$row[$assocKey]] = $row[$assocVal]; + } } else { $rows[] = $row; } @@ -298,13 +305,20 @@ function serendipity_db_probe($hash, &$errs) return false; } - $serendipity['dbConn'] = sqlite_open($serendipity['serendipityPath'] . $dbName . '.db'); + if (defined('S9Y_DATA_PATH')) { + // Shared installations! + $dbfile = S9Y_DATA_PATH . $dbName . '.db'; + } else { + $dbfile = $serendipity['serendipityPath'] . $dbName . '.db'; + } + + $serendipity['dbConn'] = sqlite_open($dbfile); if ($serendipity['dbConn']) { return true; } - $errs[] = "Unable to open \"{$serendipity['serendipityPath']}$dbName.db\" - check permissions (directory needs to be writeable for webserver)!"; + $errs[] = "Unable to open \"$dbfile\" - check permissions (directory needs to be writeable for webserver)!"; return false; }