mirror of
https://git.tt-rss.org/git/tt-rss.git
synced 2025-12-28 19:21:29 +00:00
overall directory tree cleanup
This commit is contained in:
155
include/db-prefs.php
Normal file
155
include/db-prefs.php
Normal file
@@ -0,0 +1,155 @@
|
||||
<?php
|
||||
require_once "config.php";
|
||||
require_once "db.php";
|
||||
|
||||
if (!defined('DISABLE_SESSIONS')) {
|
||||
if (!$_SESSION["prefs_cache"])
|
||||
$_SESSION["prefs_cache"] = array();
|
||||
}
|
||||
|
||||
function get_pref($link, $pref_name, $user_id = false, $die_on_error = false) {
|
||||
|
||||
$pref_name = db_escape_string($pref_name);
|
||||
$prefs_cache = true;
|
||||
$profile = false;
|
||||
|
||||
if (!$user_id) {
|
||||
$user_id = $_SESSION["uid"];
|
||||
@$profile = $_SESSION["profile"];
|
||||
} else {
|
||||
$user_id = sprintf("%d", $user_id);
|
||||
//$prefs_cache = false;
|
||||
}
|
||||
|
||||
if ($prefs_cache && !defined('DISABLE_SESSIONS')) {
|
||||
if ($_SESSION["prefs_cache"] && @$_SESSION["prefs_cache"][$pref_name]) {
|
||||
$tuple = $_SESSION["prefs_cache"][$pref_name];
|
||||
return convert_pref_type($tuple["value"], $tuple["type"]);
|
||||
}
|
||||
}
|
||||
|
||||
if ($profile) {
|
||||
$profile_qpart = "profile = '$profile' AND";
|
||||
} else {
|
||||
$profile_qpart = "profile IS NULL AND";
|
||||
}
|
||||
|
||||
if (get_schema_version($link) < 63) $profile_qpart = "";
|
||||
|
||||
$result = db_query($link, "SELECT
|
||||
value,ttrss_prefs_types.type_name as type_name
|
||||
FROM
|
||||
ttrss_user_prefs,ttrss_prefs,ttrss_prefs_types
|
||||
WHERE
|
||||
$profile_qpart
|
||||
ttrss_user_prefs.pref_name = '$pref_name' AND
|
||||
ttrss_prefs_types.id = type_id AND
|
||||
owner_uid = '$user_id' AND
|
||||
ttrss_user_prefs.pref_name = ttrss_prefs.pref_name");
|
||||
|
||||
if (db_num_rows($result) > 0) {
|
||||
$value = db_fetch_result($result, 0, "value");
|
||||
$type_name = db_fetch_result($result, 0, "type_name");
|
||||
|
||||
if (!defined('DISABLE_SESSIONS')) {
|
||||
if ($user_id == $_SESSION["uid"]) {
|
||||
$_SESSION["prefs_cache"][$pref_name]["type"] = $type_name;
|
||||
$_SESSION["prefs_cache"][$pref_name]["value"] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return convert_pref_type($value, $type_name);
|
||||
|
||||
} else {
|
||||
if ($die_on_error) {
|
||||
die("Fatal error, unknown preferences key: $pref_name");
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function convert_pref_type($value, $type_name) {
|
||||
if ($type_name == "bool") {
|
||||
return $value == "true";
|
||||
} else if ($type_name == "integer") {
|
||||
return sprintf("%d", $value);
|
||||
} else {
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
||||
function set_pref($link, $pref_name, $value, $user_id = false) {
|
||||
$pref_name = db_escape_string($pref_name);
|
||||
$value = db_escape_string($value);
|
||||
|
||||
if (!$user_id) {
|
||||
$user_id = $_SESSION["uid"];
|
||||
@$profile = $_SESSION["profile"];
|
||||
} else {
|
||||
$user_id = sprintf("%d", $user_id);
|
||||
$prefs_cache = false;
|
||||
}
|
||||
|
||||
if ($profile) {
|
||||
$profile_qpart = "AND profile = '$profile'";
|
||||
} else {
|
||||
$profile_qpart = "AND profile IS NULL";
|
||||
}
|
||||
|
||||
if (get_schema_version($link) < 63) $profile_qpart = "";
|
||||
|
||||
$type_name = "";
|
||||
$current_value = "";
|
||||
|
||||
if (!defined('DISABLE_SESSIONS')) {
|
||||
if ($_SESSION["prefs_cache"] && @$_SESSION["prefs_cache"][$pref_name]) {
|
||||
$type_name = $_SESSION["prefs_cache"][$pref_name]["type"];
|
||||
$current_value = $_SESSION["prefs_cache"][$pref_name]["value"];
|
||||
}
|
||||
}
|
||||
|
||||
if (!$type_name) {
|
||||
$result = db_query($link, "SELECT type_name
|
||||
FROM ttrss_prefs,ttrss_prefs_types
|
||||
WHERE pref_name = '$pref_name' AND type_id = ttrss_prefs_types.id");
|
||||
|
||||
if (db_num_rows($result) > 0)
|
||||
$type_name = db_fetch_result($result, 0, "type_name");
|
||||
} else if ($current_value == $value) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($type_name) {
|
||||
if ($type_name == "bool") {
|
||||
if ($value == "1" || $value == "true") {
|
||||
$value = "true";
|
||||
} else {
|
||||
$value = "false";
|
||||
}
|
||||
} else if ($type_name == "integer") {
|
||||
$value = sprintf("%d", $value);
|
||||
}
|
||||
|
||||
if ($pref_name == 'DEFAULT_ARTICLE_LIMIT' && $value == 0) {
|
||||
$value = 30;
|
||||
}
|
||||
|
||||
if ($pref_name == 'USER_TIMEZONE' && $value == '') {
|
||||
$value = 'UTC';
|
||||
}
|
||||
|
||||
db_query($link, "UPDATE ttrss_user_prefs SET
|
||||
value = '$value' WHERE pref_name = '$pref_name'
|
||||
$profile_qpart
|
||||
AND owner_uid = " . $_SESSION["uid"]);
|
||||
|
||||
if (!defined('DISABLE_SESSIONS')) {
|
||||
if ($user_id == $_SESSION["uid"]) {
|
||||
$_SESSION["prefs_cache"][$pref_name]["type"] = $type_name;
|
||||
$_SESSION["prefs_cache"][$pref_name]["value"] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
142
include/db.php
Normal file
142
include/db.php
Normal file
@@ -0,0 +1,142 @@
|
||||
<?php
|
||||
|
||||
require_once "config.php";
|
||||
|
||||
function db_connect($host, $user, $pass, $db) {
|
||||
if (DB_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);
|
||||
|
||||
if (!$link) {
|
||||
die("Connection failed: " . pg_last_error($link));
|
||||
}
|
||||
|
||||
return $link;
|
||||
|
||||
} else if (DB_TYPE == "mysql") {
|
||||
$link = mysql_connect($host, $user, $pass);
|
||||
if ($link) {
|
||||
$result = mysql_select_db($db, $link);
|
||||
if (!$result) {
|
||||
die("Can't select DB: " . mysql_error($link));
|
||||
}
|
||||
return $link;
|
||||
} else {
|
||||
die("Connection failed: " . mysql_error($link));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function db_escape_string($s, $strip_tags = true) {
|
||||
if ($strip_tags) $s = strip_tags($s);
|
||||
|
||||
if (DB_TYPE == "pgsql") {
|
||||
return pg_escape_string($s);
|
||||
} else {
|
||||
return mysql_real_escape_string($s);
|
||||
}
|
||||
}
|
||||
|
||||
function db_query($link, $query, $die_on_error = true) {
|
||||
//if ($_REQUEST["qlog"])
|
||||
// error_log($_SESSION["uid"] . ":" . $_REQUEST["op"] . "/" . $_REQUEST["subop"] .
|
||||
// " $query\n", 3, "/tmp/ttrss-query.log");
|
||||
|
||||
if (DB_TYPE == "pgsql") {
|
||||
$result = pg_query($link, $query);
|
||||
if (!$result) {
|
||||
$query = htmlspecialchars($query); // just in case
|
||||
if ($die_on_error) {
|
||||
die("Query <i>$query</i> failed [$result]: " . pg_last_error($link));
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
} else if (DB_TYPE == "mysql") {
|
||||
$result = mysql_query($query, $link);
|
||||
if (!$result) {
|
||||
$query = htmlspecialchars($query);
|
||||
if ($die_on_error) {
|
||||
die("Query <i>$query</i> failed: " . mysql_error($link));
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
function db_fetch_assoc($result) {
|
||||
if (DB_TYPE == "pgsql") {
|
||||
return pg_fetch_assoc($result);
|
||||
} else if (DB_TYPE == "mysql") {
|
||||
return mysql_fetch_assoc($result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function db_num_rows($result) {
|
||||
if (DB_TYPE == "pgsql") {
|
||||
return pg_num_rows($result);
|
||||
} else if (DB_TYPE == "mysql") {
|
||||
return mysql_num_rows($result);
|
||||
}
|
||||
}
|
||||
|
||||
function db_fetch_result($result, $row, $param) {
|
||||
if (DB_TYPE == "pgsql") {
|
||||
return pg_fetch_result($result, $row, $param);
|
||||
} else if (DB_TYPE == "mysql") {
|
||||
// I hate incoherent naming of PHP functions
|
||||
return mysql_result($result, $row, $param);
|
||||
}
|
||||
}
|
||||
|
||||
function db_unescape_string($str) {
|
||||
$tmp = str_replace("\\\"", "\"", $str);
|
||||
$tmp = str_replace("\\'", "'", $tmp);
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
function db_close($link) {
|
||||
if (DB_TYPE == "pgsql") {
|
||||
|
||||
return pg_close($link);
|
||||
|
||||
} else if (DB_TYPE == "mysql") {
|
||||
return mysql_close($link);
|
||||
}
|
||||
}
|
||||
|
||||
function db_affected_rows($link, $result) {
|
||||
if (DB_TYPE == "pgsql") {
|
||||
return pg_affected_rows($result);
|
||||
} else if (DB_TYPE == "mysql") {
|
||||
return mysql_affected_rows($link);
|
||||
}
|
||||
}
|
||||
|
||||
function db_last_error($link) {
|
||||
if (DB_TYPE == "pgsql") {
|
||||
return pg_last_error($link);
|
||||
} else if (DB_TYPE == "mysql") {
|
||||
return mysql_error($link);
|
||||
}
|
||||
}
|
||||
|
||||
function db_quote($str){
|
||||
return("'$str'");
|
||||
}
|
||||
|
||||
?>
|
||||
7647
include/functions.php
Normal file
7647
include/functions.php
Normal file
File diff suppressed because it is too large
Load Diff
57
include/localized_schema.php
Normal file
57
include/localized_schema.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php # This file has been generated at: Wed Nov 23 10:40:20 MSK 2011
|
||||
|
||||
__("Title");
|
||||
__("Title or Content");
|
||||
__("Link");
|
||||
__("Content");
|
||||
__("Article Date");
|
||||
|
||||
__("Delete article");
|
||||
__("Mark as read");
|
||||
__("Set starred");
|
||||
__("Publish article");
|
||||
__("Assign tags");
|
||||
__("Assign label");
|
||||
|
||||
__('This option is useful when you are reading several planet-type aggregators with partially colliding userbase. When disabled, it forces same posts from different feeds to appear only once.');
|
||||
__('Display expanded list of feed articles, instead of separate displays for headlines and article content');
|
||||
__('When "Mark as read" button is clicked in toolbar, automatically open next feed with unread articles.');
|
||||
__('This option enables sending daily digest of new (and unread) headlines on your configured e-mail address');
|
||||
__('This option enables marking articles as read automatically while you scroll article list.');
|
||||
__('Strip all but most common HTML tags when reading articles.');
|
||||
__('When auto-detecting tags in articles these tags will not be applied (comma-separated list).');
|
||||
__('When this option is enabled, headlines in Special feeds and Labels are grouped by feeds');
|
||||
__('Use feed-specified date to sort headlines instead of local import date.');
|
||||
__('Customize CSS stylesheet to your liking');
|
||||
__('Click to register your SSL client certificate with tt-rss');
|
||||
__('Purge old posts after this number of days (0 - disables)');
|
||||
__('Default interval between feed updates');
|
||||
__('Amount of articles to display at once');
|
||||
__('Allow duplicate posts');
|
||||
__('Enable feed categories');
|
||||
__('Show content preview in headlines list');
|
||||
__('Short date format');
|
||||
__('Long date format');
|
||||
__('Combined feed display');
|
||||
__('Hide feeds with no unread messages');
|
||||
__('On catchup show next feed');
|
||||
__('Sort feeds by unread articles count');
|
||||
__('Reverse headline order (oldest first)');
|
||||
__('Enable e-mail digest');
|
||||
__('Confirm marking feed as read');
|
||||
__('Automatically mark articles as read');
|
||||
__('Strip unsafe tags from articles');
|
||||
__('Blacklisted tags');
|
||||
__('Maximum age of fresh articles (in hours)');
|
||||
__('Mark articles in e-mail digest as read');
|
||||
__('Automatically expand articles in combined mode');
|
||||
__('Purge unread articles');
|
||||
__('Show special feeds when hiding read feeds');
|
||||
__('Group headlines in virtual feeds');
|
||||
__('Do not show images in articles');
|
||||
__('Enable external API');
|
||||
__('User timezone');
|
||||
__('Sort headlines by feed date');
|
||||
__('Customize stylesheet');
|
||||
__('Login with an SSL certificate');
|
||||
?>
|
||||
199
include/login_form.php
Normal file
199
include/login_form.php
Normal file
@@ -0,0 +1,199 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Tiny Tiny RSS : Login</title>
|
||||
<link rel="stylesheet" type="text/css" href="lib/dijit/themes/claro/claro.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="tt-rss.css">
|
||||
<link rel="shortcut icon" type="image/png" href="images/favicon.png">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<script type="text/javascript" src="lib/dojo/dojo.js" djConfig="parseOnLoad: true"></script>
|
||||
<script type="text/javascript" src="lib/prototype.js"></script>
|
||||
<script type="text/javascript" src="lib/scriptaculous/scriptaculous.js?load=effects,dragdrop,controls"></script>
|
||||
<script type="text/javascript" src="functions.js"></script>
|
||||
<script type="text/javascript" charset="utf-8" src="errors.php?mode=js"></script>
|
||||
</head>
|
||||
|
||||
<body id="ttrssLogin" class="claro">
|
||||
|
||||
<script type="text/javascript">
|
||||
function init() {
|
||||
|
||||
dojo.require("dijit.Dialog");
|
||||
|
||||
var test = setCookie("ttrss_test", "TEST");
|
||||
|
||||
if (getCookie("ttrss_test") != "TEST") {
|
||||
return fatalError(2);
|
||||
}
|
||||
|
||||
var limit_set = getCookie("ttrss_bwlimit");
|
||||
|
||||
if (limit_set == "true") {
|
||||
document.forms["loginForm"].bw_limit.checked = true;
|
||||
}
|
||||
|
||||
document.forms["loginForm"].login.focus();
|
||||
}
|
||||
|
||||
function fetchProfiles() {
|
||||
try {
|
||||
var params = Form.serialize('loginForm');
|
||||
var query = "?op=getProfiles&" + params;
|
||||
|
||||
if (query) {
|
||||
new Ajax.Request("backend.php", {
|
||||
parameters: query,
|
||||
onComplete: function(transport) {
|
||||
if (transport.responseText.match("select")) {
|
||||
$('profile_box').innerHTML = transport.responseText;
|
||||
}
|
||||
} });
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
exception_error("fetchProfiles", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function languageChange(elem) {
|
||||
try {
|
||||
document.forms['loginForm']['click'].disabled = true;
|
||||
|
||||
var lang = elem[elem.selectedIndex].value;
|
||||
setCookie("ttrss_lang", lang, <?php print SESSION_COOKIE_LIFETIME ?>);
|
||||
window.location.reload();
|
||||
} catch (e) {
|
||||
exception_error("languageChange", e);
|
||||
}
|
||||
}
|
||||
|
||||
function gotoRegForm() {
|
||||
window.location.href = "register.php";
|
||||
return false;
|
||||
}
|
||||
|
||||
function bwLimitChange(elem) {
|
||||
try {
|
||||
var limit_set = elem.checked;
|
||||
|
||||
setCookie("ttrss_bwlimit", limit_set,
|
||||
<?php print SESSION_COOKIE_LIFETIME ?>);
|
||||
|
||||
} catch (e) {
|
||||
exception_error("bwLimitChange", e);
|
||||
}
|
||||
}
|
||||
|
||||
function validateLoginForm(f) {
|
||||
try {
|
||||
|
||||
if (f.login.value.length == 0) {
|
||||
new Effect.Highlight(f.login);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (f.password.value.length == 0) {
|
||||
new Effect.Highlight(f.password);
|
||||
return false;
|
||||
}
|
||||
|
||||
document.forms['loginForm']['click'].disabled = true;
|
||||
|
||||
return true;
|
||||
} catch (e) {
|
||||
exception_error("validateLoginForm", e);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<script type="text/javascript">
|
||||
Event.observe(window, 'load', function() {
|
||||
init();
|
||||
});
|
||||
</script>
|
||||
|
||||
<form action="" method="POST" id="loginForm" name="loginForm" onsubmit="return validateLoginForm(this)">
|
||||
<input type="hidden" name="login_action" value="do_login">
|
||||
|
||||
<table class="loginForm2">
|
||||
<tr>
|
||||
<td class="loginTop" valign="bottom" align="left">
|
||||
<img src="images/logo_wide.png">
|
||||
</td>
|
||||
</tr><tr>
|
||||
<td align="center" valign="middle" class="loginMiddle" height="100%">
|
||||
<?php if ($_SESSION['login_error_msg']) { ?>
|
||||
<div class="loginError"><?php echo $_SESSION['login_error_msg'] ?></div>
|
||||
<?php $_SESSION['login_error_msg'] = ""; ?>
|
||||
<?php } ?>
|
||||
<table>
|
||||
<tr><td align="right"><?php echo __("Login:") ?></td>
|
||||
<td align="right"><input name="login"
|
||||
onchange="fetchProfiles()" onfocus="fetchProfiles()"
|
||||
value="<?php echo get_remote_user($link) ?>"></td></tr>
|
||||
<tr><td align="right"><?php echo __("Password:") ?></td>
|
||||
<td align="right"><input type="password" name="password"
|
||||
onchange="fetchProfiles()" onfocus="fetchProfiles()"
|
||||
value="<?php echo get_remote_fakepass($link) ?>"></td></tr>
|
||||
<tr><td align="right"><?php echo __("Language:") ?></td>
|
||||
<td align="right">
|
||||
<?php
|
||||
print_select_hash("language", $_COOKIE["ttrss_lang"], get_translations(),
|
||||
"style='width : 100%' onchange='languageChange(this)'");
|
||||
|
||||
?>
|
||||
</td></tr>
|
||||
|
||||
<tr><td align="right"><?php echo __("Profile:") ?></td>
|
||||
<td align="right" id="profile_box">
|
||||
<select style='width : 100%' disabled='disabled'>
|
||||
<option><?php echo __("Default profile") ?></option></select>
|
||||
</td></tr>
|
||||
|
||||
<!-- <tr><td colspan="2">
|
||||
<input type="checkbox" name="remember_me" id="remember_me">
|
||||
<label for="remember_me">Remember me on this computer</label>
|
||||
</td></tr> -->
|
||||
|
||||
<tr><td colspan="2" align="right" class="innerLoginCell">
|
||||
|
||||
<button type="submit" name='click'><?php echo __('Log in') ?></button>
|
||||
<?php if (defined('ENABLE_REGISTRATION') && ENABLE_REGISTRATION) { ?>
|
||||
<button onclick="return gotoRegForm()">
|
||||
<?php echo __("Create new account") ?></button>
|
||||
<?php } ?>
|
||||
|
||||
<input type="hidden" name="action" value="login">
|
||||
<input type="hidden" name="rt"
|
||||
value="<?php if ($return_to != 'none') { echo $return_to; } ?>">
|
||||
</td></tr>
|
||||
|
||||
<tr><td colspan="2" align="right" class="innerLoginCell">
|
||||
|
||||
<div class="small">
|
||||
<input name="bw_limit" id="bw_limit" type="checkbox"
|
||||
onchange="bwLimitChange(this)">
|
||||
<label for="bw_limit">
|
||||
<?php echo __("Use less traffic") ?></label></div>
|
||||
|
||||
</td></tr>
|
||||
|
||||
|
||||
</table>
|
||||
</td>
|
||||
</tr><tr>
|
||||
<td align="center" class="loginBottom">
|
||||
<a href="http://tt-rss.org/">Tiny Tiny RSS</a>
|
||||
<?php if (!defined('HIDE_VERSION')) { ?>
|
||||
v<?php echo VERSION ?>
|
||||
<?php } ?>
|
||||
© 2005–<?php echo date('Y') ?> <a href="http://fakecake.org/">Andrew Dolgov</a>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
</form>
|
||||
|
||||
</body></html>
|
||||
175
include/sanity_check.php
Normal file
175
include/sanity_check.php
Normal file
@@ -0,0 +1,175 @@
|
||||
<?php
|
||||
require_once "functions.php";
|
||||
|
||||
define('EXPECTED_CONFIG_VERSION', 23);
|
||||
define('SCHEMA_VERSION', 86);
|
||||
|
||||
if (!file_exists("config.php")) {
|
||||
print "<b>Fatal Error</b>: You forgot to copy
|
||||
<b>config.php-dist</b> to <b>config.php</b> and edit it.\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once "config.php";
|
||||
require_once "sanity_config.php";
|
||||
|
||||
if (CONFIG_VERSION != EXPECTED_CONFIG_VERSION) {
|
||||
$err_msg = "config: your config file version is incorrect. See config.php-dist.\n";
|
||||
}
|
||||
|
||||
$purifier_cache_dir = CACHE_DIR . "/htmlpurifier";
|
||||
|
||||
if (!is_writable($purifier_cache_dir)) {
|
||||
$err_msg = "config: HTMLPurifier cache directory should be writable by anyone (chmod -R 777 $purifier_cache_dir)";
|
||||
}
|
||||
|
||||
if (GENERATED_CONFIG_CHECK != EXPECTED_CONFIG_VERSION) {
|
||||
$err_msg = "config: your sanity_config.php is outdated, please recreate it using ./utils/regen_config_checks.sh";
|
||||
}
|
||||
|
||||
foreach ($requred_defines as $d) {
|
||||
if (!defined($d)) {
|
||||
$err_msg = "config: required constant $d is not defined. Please check config.php";
|
||||
}
|
||||
}
|
||||
|
||||
if (defined('RSS_BACKEND_TYPE')) {
|
||||
print "<b>Fatal error</b>: RSS_BACKEND_TYPE is deprecated. Please remove this
|
||||
option from config.php\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
if (file_exists("xml-export.php") || file_exists("xml-import.php")) {
|
||||
print "<b>Fatal Error</b>: XML Import/Export tools (<b>xml-export.php</b>
|
||||
and <b>xml-import.php</b>) could be used maliciously. Please remove them
|
||||
from your TT-RSS instance.\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
if (SINGLE_USER_MODE && DAEMON_UPDATE_LOGIN_LIMIT > 0) {
|
||||
print "<b>Fatal Error</b>: Please set DAEMON_UPDATE_LOGIN_LIMIT
|
||||
to 0 in single user mode.\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!defined('SESSION_EXPIRE_TIME')) {
|
||||
$err_msg = "config: SESSION_EXPIRE_TIME is undefined";
|
||||
}
|
||||
|
||||
if (SESSION_EXPIRE_TIME < 60) {
|
||||
$err_msg = "config: SESSION_EXPIRE_TIME is too low (less than 60)";
|
||||
}
|
||||
|
||||
if (SESSION_EXPIRE_TIME < SESSION_COOKIE_LIFETIME) {
|
||||
$err_msg = "config: SESSION_EXPIRE_TIME should be greater or equal to" .
|
||||
"SESSION_COOKIE_LIFETIME";
|
||||
}
|
||||
|
||||
/* if (defined('DISABLE_SESSIONS')) {
|
||||
$err_msg = "config: you have enabled DISABLE_SESSIONS. Please disable this option.";
|
||||
} */
|
||||
|
||||
if (DATABASE_BACKED_SESSIONS && SINGLE_USER_MODE) {
|
||||
$err_msg = "config: DATABASE_BACKED_SESSIONS is incompatible with SINGLE_USER_MODE";
|
||||
}
|
||||
|
||||
if (DATABASE_BACKED_SESSIONS && DB_TYPE == "mysql") {
|
||||
$err_msg = "config: DATABASE_BACKED_SESSIONS are currently broken with MySQL";
|
||||
}
|
||||
|
||||
if (SINGLE_USER_MODE) {
|
||||
$link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
|
||||
|
||||
if ($link) {
|
||||
$result = db_query($link, "SELECT id FROM ttrss_users WHERE id = 1");
|
||||
|
||||
if (db_num_rows($result) != 1) {
|
||||
$err_msg = "config: SINGLE_USER_MODE is enabled but default admin account (UID=1) is not found.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (defined('MAIL_FROM')) {
|
||||
$err_msg = "config: MAIL_FROM has been split into DIGEST_FROM_NAME and DIGEST_FROM_ADDRESS";
|
||||
}
|
||||
|
||||
if (!defined('COUNTERS_MAX_AGE')) {
|
||||
$err_msg = "config: option COUNTERS_MAX_AGE expected, but not defined";
|
||||
}
|
||||
|
||||
if (defined('DAEMON_REFRESH_ONLY')) {
|
||||
$err_msg = "config: option DAEMON_REFRESH_ONLY is obsolete. Please remove this option and read about other ways to update feeds on the <a href='http://tt-rss.org/wiki/UpdatingFeeds'>wiki</a>.";
|
||||
|
||||
}
|
||||
|
||||
if (defined('ENABLE_SIMPLEPIE')) {
|
||||
$err_msg = "config: ENABLE_SIMPLEPIE is obsolete and replaced with DEFAULT_UPDATE_METHOD. Please adjust your config.php.";
|
||||
}
|
||||
|
||||
if (!defined('DEFAULT_UPDATE_METHOD') || (DEFAULT_UPDATE_METHOD != 0 &&
|
||||
DEFAULT_UPDATE_METHOD != 1)) {
|
||||
$err_msg = "config: DEFAULT_UPDATE_METHOD should be either 0 or 1.";
|
||||
}
|
||||
|
||||
if (SELF_URL_PATH == "http://yourserver/tt-rss/") {
|
||||
$err_msg = "config: please set SELF_URL_PATH to the correct value.";
|
||||
}
|
||||
|
||||
if (!is_writable(ICONS_DIR)) {
|
||||
$err_msg = "config: your ICONS_DIR (" . ICONS_DIR . ") is not writable.\n";
|
||||
}
|
||||
|
||||
if (ini_get("open_basedir")) {
|
||||
$err_msg = "php.ini: open_basedir is not supported.";
|
||||
}
|
||||
|
||||
if (!function_exists("curl_init") && !ini_get("allow_url_fopen")) {
|
||||
$err_msg = "php.ini: either allow_url_fopen or CURL needs to be enabled.";
|
||||
}
|
||||
|
||||
if (!function_exists("json_encode")) {
|
||||
$err_msg = "PHP: json functions not found.";
|
||||
}
|
||||
|
||||
if (DB_TYPE == "mysql" && !function_exists("mysql_connect")) {
|
||||
$err_msg = "PHP: MySQL functions not found.";
|
||||
}
|
||||
|
||||
if (DB_TYPE == "pgsql" && !function_exists("pg_connect")) {
|
||||
$err_msg = "PHP: PostgreSQL functions not found.";
|
||||
}
|
||||
|
||||
if (!function_exists("mb_strlen")) {
|
||||
$err_msg = "PHP: mbstring functions not found.";
|
||||
}
|
||||
|
||||
if (!function_exists("ctype_lower")) {
|
||||
$err_msg = "PHP: ctype functions not found (required for HTMLPurifier).";
|
||||
}
|
||||
|
||||
if (ini_get("safe_mode")) {
|
||||
$err_msg = "php.ini: Safe mode is not supported. If you wish to continue, remove this test from sanity_check.php and proceeed at your own risk. Please note that your bug reports will not be accepted or reviewed.";
|
||||
}
|
||||
|
||||
if ((PUBSUBHUBBUB_HUB || PUBSUBHUBBUB_ENABLED) && !function_exists("curl_init")) {
|
||||
$err_msg = "CURL is required for PubSubHubbub support.";
|
||||
}
|
||||
|
||||
if (!class_exists("DOMDocument")) {
|
||||
$err_msg = "PHP: DOMDocument extension not found.";
|
||||
}
|
||||
|
||||
if (SELF_URL_PATH == "http://local.host/tt-rss") {
|
||||
$err_msg = "config: please set SELF_URL_PATH to the correct value";
|
||||
}
|
||||
|
||||
if (!ISCONFIGURED) {
|
||||
$err_msg = "config: please read config.php completely.";
|
||||
}
|
||||
|
||||
if ($err_msg) {
|
||||
print "<b>Fatal Error</b>: $err_msg\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
?>
|
||||
3
include/sanity_config.php
Normal file
3
include/sanity_config.php
Normal file
@@ -0,0 +1,3 @@
|
||||
<?php # This file has been generated at: Tue Apr 26 18:40:48 MSD 2011
|
||||
define('GENERATED_CONFIG_CHECK', 23);
|
||||
$requred_defines = array( 'DB_TYPE', 'DB_HOST', 'DB_USER', 'DB_NAME', 'DB_PASS', 'SELF_URL_PATH', 'SINGLE_USER_MODE', 'CACHE_DIR', 'SIMPLEPIE_CACHE_IMAGES', 'ICONS_DIR', 'ICONS_URL', 'TMP_DIRECTORY', 'DAEMON_SLEEP_INTERVAL', 'DATABASE_BACKED_SESSIONS', 'SESSION_CHECK_ADDRESS', 'SESSION_COOKIE_LIFETIME', 'SESSION_EXPIRE_TIME', 'DAEMON_UPDATE_LOGIN_LIMIT', 'CHECK_FOR_NEW_VERSION', 'DIGEST_ENABLE', 'DIGEST_EMAIL_LIMIT', 'DAEMON_SENDS_DIGESTS', 'MYSQL_CHARSET', 'DEFAULT_UPDATE_METHOD', 'COUNTERS_MAX_AGE', 'DIGEST_FROM_NAME', 'DIGEST_FROM_ADDRESS', 'DIGEST_SUBJECT', 'DIGEST_SMTP_HOST', 'DIGEST_SMTP_LOGIN', 'DIGEST_SMTP_PASSWORD', 'DAEMON_FEED_LIMIT', 'ALLOW_REMOTE_USER_AUTH', 'AUTO_LOGIN', 'AUTO_CREATE_USER', 'LOCK_DIRECTORY', 'ENABLE_GZIP_OUTPUT', 'PHP_EXECUTABLE', 'ENABLE_REGISTRATION', 'REG_NOTIFY_ADDRESS', 'REG_MAX_USERS', 'FEEDBACK_URL', 'FORCE_ARTICLE_PURGE', 'SPHINX_ENABLED', 'SPHINX_INDEX', 'ENABLE_TWEET_BUTTON', 'CONSUMER_KEY', 'CONSUMER_SECRET', 'PUBSUBHUBBUB_HUB', 'PUBSUBHUBBUB_ENABLED', 'ISCONFIGURED', 'CONFIG_VERSION'); ?>
|
||||
108
include/sessions.php
Normal file
108
include/sessions.php
Normal file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
// Original from http://www.daniweb.com/code/snippet43.html
|
||||
|
||||
require_once "config.php";
|
||||
require_once "db.php";
|
||||
|
||||
$session_expire = SESSION_EXPIRE_TIME; //seconds
|
||||
$session_name = (!defined('TTRSS_SESSION_NAME')) ? "ttrss_sid" : TTRSS_SESSION_NAME;
|
||||
|
||||
if ($_SERVER['HTTPS'] == "on") {
|
||||
$session_name .= "_ssl";
|
||||
ini_set("session.cookie_secure", true);
|
||||
}
|
||||
|
||||
ini_set("session.gc_probability", 50);
|
||||
ini_set("session.name", $session_name);
|
||||
ini_set("session.use_only_cookies", true);
|
||||
ini_set("session.gc_maxlifetime", SESSION_EXPIRE_TIME);
|
||||
|
||||
function ttrss_open ($s, $n) {
|
||||
|
||||
global $session_connection;
|
||||
|
||||
$session_connection = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function ttrss_read ($id){
|
||||
|
||||
global $session_connection,$session_read;
|
||||
|
||||
$query = "SELECT data FROM ttrss_sessions WHERE id='$id'";
|
||||
|
||||
$res = db_query($session_connection, $query);
|
||||
|
||||
if (db_num_rows($res) != 1) {
|
||||
return "";
|
||||
} else {
|
||||
$session_read = db_fetch_assoc($res);
|
||||
$session_read["data"] = base64_decode($session_read["data"]);
|
||||
return $session_read["data"];
|
||||
}
|
||||
}
|
||||
|
||||
function ttrss_write ($id, $data) {
|
||||
|
||||
if (! $data) {
|
||||
return false;
|
||||
}
|
||||
|
||||
global $session_connection, $session_read, $session_expire;
|
||||
|
||||
$expire = time() + $session_expire;
|
||||
|
||||
$data = db_escape_string(base64_encode($data), $session_connection);
|
||||
|
||||
if ($session_read) {
|
||||
$query = "UPDATE ttrss_sessions SET data='$data',
|
||||
expire='$expire' WHERE id='$id'";
|
||||
} else {
|
||||
$query = "INSERT INTO ttrss_sessions (id, data, expire)
|
||||
VALUES ('$id', '$data', '$expire')";
|
||||
}
|
||||
|
||||
db_query($session_connection, $query);
|
||||
return true;
|
||||
}
|
||||
|
||||
function ttrss_close () {
|
||||
|
||||
global $session_connection;
|
||||
|
||||
db_close($session_connection);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function ttrss_destroy ($id) {
|
||||
|
||||
global $session_connection;
|
||||
|
||||
$query = "DELETE FROM ttrss_sessions WHERE id = '$id'";
|
||||
|
||||
db_query($session_connection, $query);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function ttrss_gc ($expire) {
|
||||
|
||||
global $session_connection;
|
||||
|
||||
$query = "DELETE FROM ttrss_sessions WHERE expire < " . time();
|
||||
|
||||
db_query($session_connection, $query);
|
||||
}
|
||||
|
||||
if (DATABASE_BACKED_SESSIONS) {
|
||||
session_set_save_handler("ttrss_open",
|
||||
"ttrss_close", "ttrss_read", "ttrss_write",
|
||||
"ttrss_destroy", "ttrss_gc");
|
||||
}
|
||||
|
||||
session_set_cookie_params(SESSION_COOKIE_LIFETIME);
|
||||
|
||||
session_start();
|
||||
?>
|
||||
3
include/version.php
Normal file
3
include/version.php
Normal file
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
define('VERSION', "1.5.7");
|
||||
?>
|
||||
Reference in New Issue
Block a user