|
|
|
<?php
|
|
|
|
|
|
|
|
define('BCRYPT_COST', 9);
|
|
|
|
|
|
|
|
Minz_Configuration::register('default_system', join_path(FRESHRSS_PATH, 'config.default.php'));
|
|
|
|
Minz_Configuration::register('default_user', join_path(FRESHRSS_PATH, 'config-user.default.php'));
|
|
|
|
|
|
|
|
function checkRequirements($dbType = '') {
|
Require PHP 5.5+ (#2495)
* Require PHP 5.5+
https://github.com/FreshRSS/FreshRSS/issues/2469#issuecomment-522255093
I think it would be reasonable to require PHP 5.5+ for the core of
FreshRSS after all.
As Frenzie said, WordPress currently requires PHP 5.6.20+, and it is the
most popular PHP application.
We would loose about 20% of the PHP servers according to
https://w3techs.com/technologies/details/pl-php/5/all but I expect this
number to drop fast after the release of CentOS 8 (CentOS accounts for
17% of Linux servers
https://w3techs.com/technologies/details/os-linux/all/all ).
Distributions:
* no impact on Ubuntu, Fedora, Alpine, OpenWRT, FreeBSD, OpenSuze,
Mageia, as all active versions have PHP > 7
* no impact on OpenSuze, Synology, as all active versions have PHP > 5.5
* we drop Debian 8 Jessie (-2020) - we keep supporting Debian 9 Stretch
(2017-06) - current is Debian 10 Buster
* we drop Red Hat 7 (-2024) - we keep supporting RHEL 8 (2019-05)
* we drop CentOS 7 (-2024) - we will support CentOS 8 (to be released
soonish)
When dropping older versions, I can better like when it is for a good
reason, and there is actually one with PHP 5.5, namely generators
(yield) https://php.net/language.generators.overview which I consider
using.
* Version note for JSON.php
* hex2bin
* Update .travis.yml
Co-Authored-By: Frans de Jonge <fransdejonge@gmail.com>
5 years ago
|
|
|
$php = version_compare(PHP_VERSION, '5.5.0') >= 0;
|
|
|
|
$minz = file_exists(join_path(LIB_PATH, 'Minz'));
|
|
|
|
$curl = extension_loaded('curl');
|
|
|
|
$pdo_mysql = extension_loaded('pdo_mysql');
|
|
|
|
$pdo_sqlite = extension_loaded('pdo_sqlite');
|
|
|
|
$pdo_pgsql = extension_loaded('pdo_pgsql');
|
|
|
|
$message = '';
|
|
|
|
switch ($dbType) {
|
|
|
|
case 'mysql':
|
|
|
|
$pdo_sqlite = $pdo_pgsql = true;
|
|
|
|
$pdo = $pdo_mysql;
|
|
|
|
break;
|
|
|
|
case 'sqlite':
|
|
|
|
$pdo_mysql = $pdo_pgsql = true;
|
|
|
|
$pdo = $pdo_sqlite;
|
|
|
|
break;
|
|
|
|
case 'pgsql':
|
|
|
|
$pdo_mysql = $pdo_sqlite = true;
|
|
|
|
$pdo = $pdo_pgsql;
|
|
|
|
break;
|
|
|
|
case '':
|
|
|
|
$pdo = $pdo_mysql || $pdo_sqlite || $pdo_pgsql;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$pdo_mysql = $pdo_sqlite = $pdo_pgsql = true;
|
|
|
|
$pdo = false;
|
|
|
|
$message = 'Invalid database type!';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
$pcre = extension_loaded('pcre');
|
|
|
|
$ctype = extension_loaded('ctype');
|
|
|
|
$fileinfo = extension_loaded('fileinfo');
|
|
|
|
$dom = class_exists('DOMDocument');
|
|
|
|
$xml = function_exists('xml_parser_create');
|
|
|
|
$json = function_exists('json_encode');
|
|
|
|
$mbstring = extension_loaded('mbstring');
|
|
|
|
$data = DATA_PATH && is_writable(DATA_PATH);
|
|
|
|
$cache = CACHE_PATH && is_writable(CACHE_PATH);
|
|
|
|
$users = USERS_PATH && is_writable(USERS_PATH);
|
|
|
|
$favicons = is_writable(join_path(DATA_PATH, 'favicons'));
|
|
|
|
$http_referer = is_referer_from_same_domain();
|
|
|
|
|
|
|
|
return array(
|
|
|
|
'php' => $php ? 'ok' : 'ko',
|
|
|
|
'minz' => $minz ? 'ok' : 'ko',
|
|
|
|
'curl' => $curl ? 'ok' : 'ko',
|
|
|
|
'pdo-mysql' => $pdo_mysql ? 'ok' : 'ko',
|
|
|
|
'pdo-sqlite' => $pdo_sqlite ? 'ok' : 'ko',
|
|
|
|
'pdo-pgsql' => $pdo_pgsql ? 'ok' : 'ko',
|
|
|
|
'pdo' => $pdo ? 'ok' : 'ko',
|
|
|
|
'pcre' => $pcre ? 'ok' : 'ko',
|
|
|
|
'ctype' => $ctype ? 'ok' : 'ko',
|
|
|
|
'fileinfo' => $fileinfo ? 'ok' : 'ko',
|
|
|
|
'dom' => $dom ? 'ok' : 'ko',
|
|
|
|
'xml' => $xml ? 'ok' : 'ko',
|
|
|
|
'json' => $json ? 'ok' : 'ko',
|
|
|
|
'mbstring' => $mbstring ? 'ok' : 'ko',
|
|
|
|
'data' => $data ? 'ok' : 'ko',
|
|
|
|
'cache' => $cache ? 'ok' : 'ko',
|
|
|
|
'users' => $users ? 'ok' : 'ko',
|
|
|
|
'favicons' => $favicons ? 'ok' : 'ko',
|
|
|
|
'http_referer' => $http_referer ? 'ok' : 'ko',
|
|
|
|
'message' => $message ?: 'ok',
|
|
|
|
'all' => $php && $minz && $curl && $pdo && $pcre && $ctype && $dom && $xml &&
|
|
|
|
$data && $cache && $users && $favicons && $http_referer && $message == '' ? 'ok' : 'ko'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function generateSalt() {
|
|
|
|
return sha1(uniqid(mt_rand(), true).implode('', stat(__FILE__)));
|
|
|
|
}
|
|
|
|
|
|
|
|
function checkDb(&$dbOptions) {
|
|
|
|
$dsn = '';
|
|
|
|
$driver_options = null;
|
|
|
|
prepareSyslog();
|
|
|
|
try {
|
|
|
|
switch ($dbOptions['type']) {
|
|
|
|
case 'mysql':
|
|
|
|
include_once(APP_PATH . '/SQL/install.sql.mysql.php');
|
|
|
|
$driver_options = array(
|
|
|
|
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4'
|
|
|
|
);
|
|
|
|
try { // on ouvre une connexion juste pour créer la base si elle n'existe pas
|
|
|
|
$dsn = 'mysql:host=' . $dbOptions['host'] . ';';
|
|
|
|
$c = new PDO($dsn, $dbOptions['user'], $dbOptions['password'], $driver_options);
|
|
|
|
$sql = sprintf(SQL_CREATE_DB, $dbOptions['base']);
|
|
|
|
$res = $c->query($sql);
|
|
|
|
} catch (PDOException $e) {
|
|
|
|
syslog(LOG_DEBUG, 'FreshRSS MySQL warning: ' . $e->getMessage());
|
|
|
|
}
|
|
|
|
// on écrase la précédente connexion en sélectionnant la nouvelle BDD
|
|
|
|
$dsn = 'mysql:host=' . $dbOptions['host'] . ';dbname=' . $dbOptions['base'];
|
|
|
|
break;
|
|
|
|
case 'sqlite':
|
|
|
|
include_once(APP_PATH . '/SQL/install.sql.sqlite.php');
|
|
|
|
$path = join_path(USERS_PATH, $dbOptions['default_user']);
|
|
|
|
if (!is_dir($path)) {
|
|
|
|
mkdir($path);
|
|
|
|
}
|
|
|
|
$dsn = 'sqlite:' . join_path($path, 'db.sqlite');
|
|
|
|
$driver_options = array(
|
|
|
|
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
case 'pgsql':
|
|
|
|
include_once(APP_PATH . '/SQL/install.sql.pgsql.php');
|
|
|
|
$driver_options = array(
|
|
|
|
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
|
|
|
);
|
|
|
|
try { // on ouvre une connexion juste pour créer la base si elle n'existe pas
|
|
|
|
$dsn = 'pgsql:host=' . $dbOptions['host'] . ';dbname=postgres';
|
|
|
|
$c = new PDO($dsn, $dbOptions['user'], $dbOptions['password'], $driver_options);
|
|
|
|
$sql = sprintf(SQL_CREATE_DB, $dbOptions['base']);
|
|
|
|
$res = $c->query($sql);
|
|
|
|
} catch (PDOException $e) {
|
|
|
|
syslog(LOG_DEBUG, 'FreshRSS PostgreSQL warning: ' . $e->getMessage());
|
|
|
|
}
|
|
|
|
// on écrase la précédente connexion en sélectionnant la nouvelle BDD
|
|
|
|
$dsn = 'pgsql:host=' . $dbOptions['host'] . ';dbname=' . $dbOptions['base'];
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
$c = new PDO($dsn, $dbOptions['user'], $dbOptions['password'], $driver_options);
|
|
|
|
$res = $c->query('SELECT 1');
|
|
|
|
} catch (PDOException $e) {
|
|
|
|
$dsn = '';
|
|
|
|
syslog(LOG_DEBUG, 'FreshRSS SQL warning: ' . $e->getMessage());
|
|
|
|
$dbOptions['error'] = $e->getMessage();
|
|
|
|
}
|
|
|
|
$dbOptions['dsn'] = $dsn;
|
|
|
|
$dbOptions['options'] = $driver_options;
|
|
|
|
return $dsn != '';
|
|
|
|
}
|
|
|
|
|
|
|
|
function deleteInstall() {
|
|
|
|
$path = join_path(DATA_PATH, 'do-install.txt');
|
|
|
|
@unlink($path);
|
|
|
|
return !file_exists($path);
|
|
|
|
}
|