";
+ return null;
+ }
}
function make_config($DB_TYPE, $DB_HOST, $DB_USER, $DB_NAME, $DB_PASS,
@@ -136,12 +111,6 @@
$finished = false;
- if (function_exists("mcrypt_decrypt")) {
- $crypt_key = make_password(24);
- } else {
- $crypt_key = "";
- }
-
foreach ($data as $line) {
if (preg_match("/define\('DB_TYPE'/", $line)) {
$rv .= "\tdefine('DB_TYPE', '$DB_TYPE');\n";
@@ -157,8 +126,6 @@
$rv .= "\tdefine('DB_PORT', '$DB_PORT');\n";
} else if (preg_match("/define\('SELF_URL_PATH'/", $line)) {
$rv .= "\tdefine('SELF_URL_PATH', '$SELF_URL_PATH');\n";
- } else if (preg_match("/define\('FEED_CRYPT_KEY'/", $line)) {
- $rv .= "\tdefine('FEED_CRYPT_KEY', '$crypt_key');\n";
} else if (!$finished) {
$rv .= "$line\n";
}
@@ -171,35 +138,12 @@
return $rv;
}
- function db_query($link, $query, $type, $die_on_error = true) {
- if ($type == "pgsql") {
- $result = pg_query($link, $query);
- if (!$result) {
- $query = htmlspecialchars($query); // just in case
- if ($die_on_error) {
- die("Query $query failed [$result]: " . ($link ? pg_last_error($link) : "No connection"));
- }
- }
- return $result;
- } else if ($type == "mysql") {
-
- if (function_exists("mysqli_connect")) {
- $result = mysqli_query($link, $query);
- } else {
- $result = mysql_query($query, $link);
- }
- if (!$result) {
- $query = htmlspecialchars($query);
- if ($die_on_error) {
- die("Query $query failed: " . ($link ? function_exists("mysqli_connect") ? mysqli_error($link) : mysql_error($link) : "No connection"));
- }
- }
- return $result;
- }
+ function is_server_https() {
+ return (!empty($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] != 'off')) || (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https');
}
function make_self_url_path() {
- $url_path = ((!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != "on") ? 'http://' : 'https://') . $_SERVER["HTTP_HOST"] . parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH);
+ $url_path = (is_server_https() ? 'https://' : 'http://') . $_SERVER["HTTP_HOST"] . parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH);
return $url_path;
}
@@ -258,28 +202,28 @@
@@ -289,7 +233,7 @@
@@ -324,6 +268,22 @@
array_push($notices, "It is highly recommended to enable support for CURL in PHP.");
}
+ if (function_exists("curl_init") && ini_get("open_basedir")) {
+ array_push($notices, "CURL and open_basedir combination breaks support for HTTP redirects. See the FAQ for more information.");
+ }
+
+ if (!function_exists("idn_to_ascii")) {
+ array_push($notices, "PHP support for Internationalization Functions is required to handle Internationalized Domain Names.");
+ }
+
+ if ($DB_TYPE == "mysql" && !function_exists("mysqli_connect")) {
+ array_push($notices, "PHP extension for MySQL (mysqli) is missing. This may prevent legacy plugins from working.");
+ }
+
+ if ($DB_TYPE == "pgsql" && !function_exists("pg_connect")) {
+ array_push($notices, "PHP extension for PostgreSQL is missing. This may prevent legacy plugins from working.");
+ }
+
if (count($notices) > 0) {
print_notice("Configuration check succeeded with minor problems:");
@@ -343,9 +303,9 @@
Checking database
Before you can start using tt-rss, database needs to be initialized. Click on the button below to do that now.
query("SELECT true FROM ttrss_feeds");
- if ($result) {
- print_error("Existing tt-rss tables will be removed from the database. If you would like to keep your data, skip database initialization.");
+ if ($res && $res->fetch()) {
+ print_error("Some tt-rss data already exists in this database. If you continue with database initialization your current data will be lost.");
$need_confirm = true;
} else {
$need_confirm = false;
@@ -406,9 +366,9 @@
} else if ($op == 'installschema' || $op == 'skipschema') {
- $link = db_connect($DB_HOST, $DB_USER, $DB_PASS, $DB_NAME, $DB_TYPE, $DB_PORT);
+ $pdo = pdo_connect($DB_HOST, $DB_USER, $DB_PASS, $DB_NAME, $DB_TYPE, $DB_PORT);
- if (!$link) {
+ if (!$pdo) {
print_error("Unable to connect to database using specified parameters.");
exit;
}
@@ -417,11 +377,17 @@
print "