Exemplo n.º 1
0
            _setlocale(LC_MESSAGES, $lang);
        } else {
            if (defined('LC_ALL')) {
                _setlocale(LC_ALL, $lang);
            }
        }
        if (defined('MOBILE_VERSION')) {
            _bindtextdomain("messages", "../locale");
        } else {
            _bindtextdomain("messages", "locale");
        }
        _textdomain("messages");
        _bind_textdomain_codeset("messages", "UTF-8");
    }
}
startup_gettext();
require_once 'db-prefs.php';
require_once 'version.php';
require_once 'ccache.php';
require_once 'labels.php';
define('SELF_USER_AGENT', 'Tiny Tiny RSS/' . VERSION . ' (http://tt-rss.org/)');
ini_set('user_agent', SELF_USER_AGENT);
require_once 'lib/pubsubhubbub/publisher.php';
require_once 'lib/htmLawed.php';
$tz_offset = -1;
$utc_tz = new DateTimeZone('UTC');
$schema_version = false;
/**
 * Print a timestamped debug message.
 *
 * @param string $msg The debug message.
Exemplo n.º 2
0
function login_sequence()
{
    if (SINGLE_USER_MODE) {
        @session_start();
        authenticate_user("admin", null);
        startup_gettext();
        load_user_plugins($_SESSION["uid"]);
    } else {
        if (!validate_session()) {
            $_SESSION["uid"] = false;
        }
        if (!$_SESSION["uid"]) {
            if (AUTH_AUTO_LOGIN && authenticate_user(null, null)) {
                $_SESSION["ref_schema_version"] = get_schema_version(true);
            } else {
                authenticate_user(null, null, true);
            }
            if (!$_SESSION["uid"]) {
                @session_destroy();
                setcookie(session_name(), '', time() - 42000, '/');
                render_login_form();
                exit;
            }
        } else {
            /* bump login timestamp */
            db_query("UPDATE ttrss_users SET last_login = NOW() WHERE id = " . $_SESSION["uid"]);
            $_SESSION["last_login_update"] = time();
        }
        if ($_SESSION["uid"]) {
            startup_gettext();
            load_user_plugins($_SESSION["uid"]);
            /* cleanup ccache */
            db_query("DELETE FROM ttrss_counters_cache WHERE owner_uid = " . $_SESSION["uid"] . " AND\n\t\t\t\t\t\t(SELECT COUNT(id) FROM ttrss_feeds WHERE\n\t\t\t\t\t\t\tttrss_feeds.id = feed_id) = 0");
            db_query("DELETE FROM ttrss_cat_counters_cache WHERE owner_uid = " . $_SESSION["uid"] . " AND\n\t\t\t\t\t\t(SELECT COUNT(id) FROM ttrss_feed_categories WHERE\n\t\t\t\t\t\t\tttrss_feed_categories.id = feed_id) = 0");
        }
    }
}
    function dbupdate()
    {
        startup_gettext();
        if (!SINGLE_USER_MODE && $_SESSION["access_level"] < 10) {
            $_SESSION["login_error_msg"] = __("Your access level is insufficient to run this script.");
            render_login_form();
            exit;
        }
        ?>
<html>
			<head>
			<title>Database Updater</title>
			<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
			<link rel="stylesheet" type="text/css" href="css/utility.css"/>
			</head>
			<style type="text/css">
				span.ok { color : #009000; font-weight : bold; }
				span.err { color : #ff0000; font-weight : bold; }
			</style>
		<body>
			<script type='text/javascript'>
			function confirmOP() {
				return confirm("Update the database?");
			}
			</script>

			<div class="floatingLogo"><img src="images/logo_small.png"></div>

			<h1><?php 
        echo __("Database Updater");
        ?>
</h1>

			<div class="content">

			<?php 
        @($op = $_REQUEST["subop"]);
        $updater = new DbUpdater(Db::get(), DB_TYPE, SCHEMA_VERSION);
        if ($op == "performupdate") {
            if ($updater->isUpdateRequired()) {
                print "<h2>Performing updates</h2>";
                print "<h3>Updating to schema version " . SCHEMA_VERSION . "</h3>";
                print "<ul>";
                for ($i = $updater->getSchemaVersion() + 1; $i <= SCHEMA_VERSION; $i++) {
                    print "<li>Performing update up to version {$i}...";
                    $result = $updater->performUpdateTo($i);
                    if (!$result) {
                        print "<span class='err'>FAILED!</span></li></ul>";
                        print_warning("One of the updates failed. Either retry the process or perform updates manually.");
                        print "<p><form method=\"GET\" action=\"index.php\">\n\t\t\t\t\t\t\t\t<input type=\"submit\" value=\"" . __("Return to Tiny Tiny RSS") . "\">\n\t\t\t\t\t\t\t\t</form>";
                        break;
                    } else {
                        print "<span class='ok'>OK!</span></li>";
                    }
                }
                print "</ul>";
                print_notice("Your Tiny Tiny RSS database is now updated to the latest version.");
                print "<p><form method=\"GET\" action=\"index.php\">\n\t\t\t\t\t\t<input type=\"submit\" value=\"" . __("Return to Tiny Tiny RSS") . "\">\n\t\t\t\t\t\t</form>";
            } else {
                print "<h2>Your database is up to date.</h2>";
                print "<p><form method=\"GET\" action=\"index.php\">\n\t\t\t\t\t\t<input type=\"submit\" value=\"" . __("Return to Tiny Tiny RSS") . "\">\n\t\t\t\t\t\t</form>";
            }
        } else {
            if ($updater->isUpdateRequired()) {
                print "<h2>Database update required</h2>";
                print "<h3>";
                printf("Your Tiny Tiny RSS database needs update to the latest version: %d to %d.", $updater->getSchemaVersion(), SCHEMA_VERSION);
                print "</h3>";
                print_warning("Please backup your database before proceeding.");
                print "<form method='POST'>\n\t\t\t\t\t\t\t<input type='hidden' name='subop' value='performupdate'>\n\t\t\t\t\t\t\t<input type='submit' onclick='return confirmOP()' value='" . __("Perform updates") . "'>\n\t\t\t\t\t\t</form>";
            } else {
                print_notice("Tiny Tiny RSS database is up to date.");
                print "<p><form method=\"GET\" action=\"index.php\">\n\t\t\t\t\t\t\t<input type=\"submit\" value=\"" . __("Return to Tiny Tiny RSS") . "\">\n\t\t\t\t\t\t</form>";
            }
        }
        ?>

			</div>
			</body>
			</html>
		<?php 
    }