thing of a DB layer dies unexpectedly in simple WHERE x IN (...) queries.
Also fix some HTTP Port issues, Cookie authentication and category ACL issues.
Thanks a bunch to Mark Kubacki!
}
}
+function serendipity_db_in_sql($col, &$search_ids) {
+ return $col . " IN (" . implode(', ', $search_ids) . ")";
+}
+
/* Issues a query to the underlying database;
* returns:
* false if there was an error,
}
}
+function serendipity_db_in_sql($col, &$search_ids) {
+ return $col . " IN (" . implode(', ', $search_ids) . ")";
+}
+
/* Issues a query to the underlying database;
* returns:
* false if there was an error,
}
}
+function serendipity_db_in_sql($col, &$search_ids) {
+ return $col . " IN (" . implode(', ', $search_ids) . ")";
+}
+
function serendipity_db_connect() {
global $serendipity;
return $row;
}
+function serendipity_db_in_sql($col, &$search_ids, $type = ' OR ') {
+ $sql = array();
+ if (!is_array($search_ids)) {
+ return false;
+ }
+
+ foreach($search_ids AS $id) {
+ $sql[] = $col . ' = ' . $id;
+ }
+
+ $cond = '(' . implode($type, $sql) . ')';
+ return $cond;
+}
+
function &serendipity_db_query($sql, $single = false, $result_type = "both", $reportErr = true, $assocKey = false, $assocVal = false, $expectError = false)
{
global $serendipity;
static $debug = false;
- if ($debug) $fp = @fopen('sqlite.log', 'a');
-
+ if ($debug) {
+ // Open file and write directly. In case of crashes, the pointer needs to be killed.
+ $fp = @fopen('sqlite.log', 'a');
+ 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 {
var_dump($sql);
return "problem with query";
}
- if ($debug) fwrite($fp, '[' . date('d.m.Y H:i') . '] [ERROR] SQLITE QUERY: ' . $sql . "\n\n");
+ if ($debug) {
+ $fp = @fopen('sqlite.log', 'a');
+ fwrite($fp, '[' . date('d.m.Y H:i') . '] [ERROR] ' . "\n\n");
+ fclose($fp);
+ }
return false;
- } elseif ($debug) {
- fwrite($fp, '[' . date('d.m.Y H:i') . '] SQLITE QUERY: ' . $sql . "\n\n");
}
if ($res === true) {
}
}
- if ($debug) fwrite($fp, '[' . date('d.m.Y H:i') . '] SQLITE RESULT: ' . print_r($rows, true). "\n\n");
- if ($debug) fclose($fp);
+ if ($debug) {
+ $fp = @fopen('sqlite.log', 'a');
+ fwrite($fp, '[' . date('d.m.Y H:i') . '] SQLITE RESULT: ' . print_r($rows, true). "\n\n");
+ fclose($fp);
+ }
if ($single && count($rows) == 1) {
return $rows[0];
}
} elseif ( isset($serendipity['COOKIE']['author_information']) ) {
$cookie = unserialize(base64_decode($serendipity['COOKIE']['author_information']));
- if (serendipity_authenticate_author($cookie['username'], $cookie['password'], $use_external)) {
+ if (serendipity_authenticate_author($cookie['username'], $cookie['password'], false, $use_external)) {
return true;
} else {
serendipity_deleteCookie('author_information');
if (!isset($serendipity['enableACL']) || $serendipity['enableACL'] == true) {
if ($_SESSION['serendipityAuthedUser'] === true) {
$read_id = (int)$serendipity['authorid'];
- $read_id_sql = 'acl_a.groupid';
+ $read_id_sql = 'acl_a.groupid OR acl_acc.groupid = 0';
} else {
// "0" as category property counts as "anonymous viewers"
$read_id = 0;
// When in Admin-Mode, apply readership permissions.
$cond['and'] .= " (
c.categoryid IS NULL
- OR ( acl_acc.groupid = " . $read_id_sql . " )
+ OR ( acl_acc.groupid = " . $read_id_sql . ")
OR ( acl_acc.artifact_id IS NULL
" . (isset($serendipity['GET']['adminModule']) &&
$serendipity['GET']['adminModule'] == 'entries' &&
ORDER BY {$cond['orderby']}
$limit";
+ // DEBUG:
+ // die($query);
$ret = serendipity_db_query($query);
if (is_string($ret)) {
FROM {$serendipity['dbPrefix']}category AS c
LEFT JOIN {$serendipity['dbPrefix']}entrycat AS ec
ON ec.categoryid = c.categoryid
- WHERE ec.entryid IN (" . implode(', ', $search_ids) . ")";
+ WHERE " . serendipity_db_in_sql('ec.entryid', $search_ids);
$search_ret = serendipity_db_query($query);
if ( (isset($serendipity['autodetect_baseURL']) && serendipity_db_bool($serendipity['autodetect_baseURL'])) ||
(isset($serendipity['embed']) && serendipity_db_bool($serendipity['embed'])) ) {
- $serendipity['baseURL'] = 'http' . (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 's' : '') . '://' . $_SERVER['HTTP_HOST'] . (!empty($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] != '80' ? ':' . $_SERVER['SERVER_PORT'] : '') . $serendipity['serendipityHTTPPath'];
+ $serendipity['baseURL'] = 'http' . (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 's' : '') . '://' . $_SERVER['HTTP_HOST'] . (!strstr($_SERVER['HTTP_HOST'], ':') && !empty($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] != '80' ? ':' . $_SERVER['SERVER_PORT'] : '') . $serendipity['serendipityHTTPPath'];
}
/*