function sanity_check($db_type) {
$errors = array();
if (version_compare(PHP_VERSION, '5.3.0', '<')) {
array_push($errors, "PHP version 5.3.0 or newer required.");
}
if (ini_get("open_basedir")) {
array_push($errors, "PHP configuration option open_basedir is not supported. Please disable this in PHP settings file (php.ini).");
}
if (!function_exists("curl_init") && !ini_get("allow_url_fopen")) {
array_push($errors, "PHP configuration option allow_url_fopen is disabled, and CURL functions are not present. Either enable allow_url_fopen or install PHP extension for CURL.");
}
if (!function_exists("json_encode")) {
array_push($errors, "PHP support for JSON is required, but was not found.");
}
if ($db_type == "mysql" && !function_exists("mysql_connect")) {
array_push($errors, "PHP support for MySQL is required for configured $db_type in config.php.");
}
if ($db_type == "pgsql" && !function_exists("pg_connect")) {
array_push($errors, "PHP support for PostgreSQL is required for configured $db_type in config.php");
}
if (!function_exists("mb_strlen")) {
array_push($errors, "PHP support for mbstring functions is required but was not found.");
}
if (!function_exists("hash")) {
array_push($errors, "PHP support for hash() function is required but was not found.");
}
if (!function_exists("ctype_lower")) {
array_push($errors, "PHP support for ctype functions are required by HTMLPurifier.");
}
if (!function_exists("iconv")) {
array_push($errors, "PHP support for iconv is required to handle multiple charsets.");
}
/* if (ini_get("safe_mode")) {
array_push($errors, "PHP safe mode setting is not supported.");
} */
if ((PUBSUBHUBBUB_HUB || PUBSUBHUBBUB_ENABLED) && !function_exists("curl_init")) {
array_push($errors, "PHP support for CURL is required for PubSubHubbub.");
}
if (!class_exists("DOMDocument")) {
array_push($errors, "PHP support for DOMDocument is required, but was not found.");
}
return $errors;
}
function print_error($msg) {
print " $msg
";
}
function print_notice($msg) {
print "
$msg
";
}
function db_connect($host, $user, $pass, $db, $type) {
if ($type == "pgsql") {
$string = "dbname=$db user=$user";
if ($pass) {
$string .= " password=$pass";
}
if ($host) {
$string .= " host=$host";
}
if (defined('DB_PORT')) {
$string = "$string port=" . DB_PORT;
}
$link = pg_connect($string);
return $link;
} else if ($type == "mysql") {
$link = mysql_connect($host, $user, $pass);
if ($link) {
$result = mysql_select_db($db, $link);
return $link;
}
}
}
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") {
$result = mysql_query($query, $link);
if (!$result) {
$query = htmlspecialchars($query);
if ($die_on_error) {
die("Query $query failed: " . ($link ? mysql_error($link) : "No connection"));
}
}
return $result;
}
}
?>
Tiny Tiny RSS Installer
Database settings
Checking configuration
0) {
print "Some configuration tests failed. Please correct them before continuing.
";
print "";
foreach ($errors as $error) {
print "- $error
";
}
print "
";
exit;
}
?>
Checking database
Initialize database
Before you can start using tt-rss, database needs to be initialized. Click on the button below to do that now.
Initializing database...";
$lines = explode(";", preg_replace("/[\r\n]/", "", file_get_contents("../schema/ttrss_schema_".basename($DB_TYPE).".sql")));
foreach ($lines as $line) {
if (strpos($line, "--") !== 0 && $line) {
db_query($link, $line, $DB_TYPE);
}
}
print_notice("Database initialization completed.");
} else {
print_notice("Database initialization skipped.");
}
print "Generated configuration file
";
print "Copy following text and save as config.php in tt-rss main directory. It is suggested to read through the file to the end in case you need any options changed fom default values.
";
print "";
print "You can generate the file again by changing the form above.
";
}
?>