Update config.php

Preliminary code to check for DB version
This commit is contained in:
Brian Huisman 2023-05-05 12:58:28 -04:00
parent 803155547d
commit 8a8623b440
2 changed files with 49 additions and 29 deletions

View file

@ -6,7 +6,7 @@ $_RDATA = array();
require __DIR__.'/config.ini.php';
// Check version compatibility
// Check PHP version compatibility
if (PHP_VERSION_ID < 70200)
throw new Exception('Orcinus Site Search requires a PHP version ">= 7.2.0". You are running '.PHP_VERSION.'.');
@ -24,6 +24,26 @@ if ($err[0])
$_DDATA['pdo']->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
$_DDATA['pdo']->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
$version = $_DDATA['pdo']->query('SELECT VERSION() AS `sql_version`;');
$err = $version->errorInfo();
if ($err[0] != '00000')
throw new Exception('Could not read database version: '.$err[2]);
$version = $version->fetchAll();
$_DDATA['version'] = $version[0]['sql_version'];
// Check Database version compatibility
if (preg_match('/^(\d+)\.(\d+)\.(\d+)-?(.*)$/', $_DDATA['version'], $ver)) {
// if (strpos($ver[4], 'MariaDB') === 0) {
// if ((int)$ver[1] < 10 || (int)$ver[3] < 5)
// throw new Exception('Orcinus Site Search requires a MariaDB version ">= 10.0.5". You are running '.$_DDATA['version'].'.');
// } else {
// if ((int)$ver[1] < 8 || (int)$ver[3] < 17)
// throw new Exception('Orcinus Site Search requires a MySQL version ">= 8.0.17". You are running '.$_DDATA['version'].'.');
// }
}
$_DDATA['tables'] = $_DDATA['pdo']->query(
'SHOW TABLES FROM `'.$_DDATA['database'].'` LIKE \''.$_DDATA['tbprefix'].'%\';'
);

View file

@ -187,7 +187,7 @@ if ($_RDATA['s_searchable_pages']) {
$_SDATA['formatted'][] = $term;
// Regexp for later use pattern matching results
$_SDATA['terms'][$key][2] = preg_quote(strtolower($_SDATA['terms'][$key][1]), '/');
$_SDATA['terms'][$key][2] = preg_quote(strtolower($term), '/');
$_SDATA['terms'][$key][2] = strtr($_SDATA['terms'][$key][2], $_RDATA['s_latin_pcre']);
$_SDATA['terms'][$key][2] = '/('.$_SDATA['terms'][$key][2].')/iu';