$msg"; } function print_notice($msg) { print "
$msg
"; } function db_connect($host, $user, $pass, $db, $type, $port = false) { if ($type == "pgsql") { $string = "dbname=$db user=$user"; if ($pass) { $string .= " password=$pass"; } if ($host) { $string .= " host=$host"; } if ($port) { $string = "$string port=" . $port; } $link = pg_connect($string); return $link; } else if ($type == "mysql") { if (function_exists("mysqli_connect")) { if ($port) return mysqli_connect($host, $user, $pass, $db, $port); else return mysqli_connect($host, $user, $pass, $db); } else { $link = mysql_connect($host, $user, $pass); if ($link) { $result = mysql_select_db($db, $link); if ($result) return $link; } } } } function make_config($DB_TYPE, $DB_HOST, $DB_USER, $DB_NAME, $DB_PASS, $DB_PORT, $SELF_URL_PATH) { $data = explode("\n", file_get_contents("../config.php-dist")); $rv = ""; $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"; } else if (preg_match("/define\('DB_HOST'/", $line)) { $rv .= "\tdefine('DB_HOST', '$DB_HOST');\n"; } else if (preg_match("/define\('DB_USER'/", $line)) { $rv .= "\tdefine('DB_USER', '$DB_USER');\n"; } else if (preg_match("/define\('DB_NAME'/", $line)) { $rv .= "\tdefine('DB_NAME', '$DB_NAME');\n"; } else if (preg_match("/define\('DB_PASS'/", $line)) { $rv .= "\tdefine('DB_PASS', '$DB_PASS');\n"; } else if (preg_match("/define\('DB_PORT'/", $line)) { $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"; } if (preg_match("/\?\>/", $line)) { $finished = true; } } 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 make_self_url_path() { $url_path = ($_SERVER['HTTPS'] != "on" ? 'http://' : 'https://') . $_SERVER["HTTP_HOST"] . parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH); return $url_path; } ?>

Tiny Tiny RSS Installer

Database settings

If needed
Usually 3306 for MySQL or 5432 for PostgreSQL

Other settings

This should be set to the location your Tiny Tiny RSS will be available on.

Checking configuration

0) { print "

Some configuration tests failed. Please correct them before continuing.

"; print ""; exit; } $notices = array(); if (!function_exists("curl_init")) { array_push($notices, "It is highly recommended to enable support for CURL in PHP."); } if (count($notices) > 0) { print_notice("Configuration check succeeded with minor problems:"); print ""; } else { print_notice("Configuration check succeeded."); } ?>

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 "

After copying the file, you will be able to login with default username and password combination: admin and password. Don't forget to change the password immediately!

"; ?>
"; echo make_config($DB_TYPE, $DB_HOST, $DB_USER, $DB_NAME, $DB_PASS, $DB_PORT, $SELF_URL_PATH); print ""; ?>

We can also try saving the file automatically now.

Saving configuration file to parent directory..."; if (!file_exists("../config.php")) { $fp = fopen("../config.php", "w"); if ($fp) { $written = fwrite($fp, make_config($DB_TYPE, $DB_HOST, $DB_USER, $DB_NAME, $DB_PASS, $DB_PORT, $SELF_URL_PATH)); if ($written > 0) { print_notice("Successfully saved config.php. You can try loading tt-rss now."); } else { print_notice("Unable to write into config.php in tt-rss directory."); } fclose($fp); } else { print_error("Unable to open config.php in tt-rss directory for writing."); } } else { print_error("config.php already present in tt-rss directory, refusing to overwrite."); } } ?>