fix fatalError() not working properly

This commit is contained in:
Andrew Dolgov 2011-02-18 12:28:03 +03:00
parent d195055341
commit 6853521166
5 changed files with 56 additions and 23 deletions

View File

@ -1,4 +1,5 @@
<?php
require_once "functions.php";
$ERRORS[0] = __("Unknown error");
@ -30,4 +31,18 @@
$ERRORS[11] = "[This error is not returned by server]";
$ERRORS[12] = __("SQL escaping test failed, check your database and PHP configuration");
if ($_REQUEST['mode'] == 'js') {
header("Content-Type: text/plain; charset=UTF-8");
print "var ERRORS = [];\n";
foreach ($ERRORS as $id => $error) {
$error = preg_replace("/\n/", "", $error);
$error = preg_replace("/\"/", "\\\"", $error);
print "ERRORS[$id] = \"$error\";\n";
}
}
?>

View File

@ -503,8 +503,6 @@ function setInitParam(key, value) {
function fatalError(code, msg, ext_info) {
try {
if (!ext_info) ext_info = "N/A";
if (code == 6) {
window.location.href = "tt-rss.php";
} else if (code == 5) {
@ -513,28 +511,36 @@ function fatalError(code, msg, ext_info) {
if (msg == "") msg = "Unknown error";
var ebc = $("xebContent");
if (ebc) {
Element.show("dialog_overlay");
Element.show("errorBoxShadow");
Element.hide("xebBtn");
if (ext_info) {
if (ext_info.responseText) {
ext_info = ext_info.responseText;
}
}
ebc.innerHTML =
"<div><b>Error message:</b></div>" +
"<pre>" + msg + "</pre>" +
"<div><b>Additional information:</b></div>" +
"<textarea readonly=\"1\">" + ext_info + "</textarea>";
if (ERRORS && ERRORS[code] && !msg) {
msg = ERRORS[code];
}
var content = "<div><b>Error code:</b> " + code + "</div>" +
"<p>" + msg + "</p>";
if (ext_info) {
content = content + "<div><b>Additional information:</b></div>" +
"<textarea style='width: 100%' readonly=\"1\">" +
ext_info + "</textarea>";
}
var dialog = new dijit.Dialog({
title: "Fatal error",
style: "width: 600px",
content: content});
dialog.show();
}
return false;
} catch (e) {
exception_error("fatalError", e);
}

View File

@ -1,19 +1,30 @@
<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">
<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") {

View File

@ -266,7 +266,7 @@ function genericSanityCheck() {
setCookie("ttrss_test", "TEST");
if (getCookie("ttrss_test") != "TEST") {
fatalError(2);
return fatalError(2);
}
return true;
@ -314,7 +314,7 @@ function init() {
});
if (!genericSanityCheck())
return;
return false;
loading_set_progress(20);

View File

@ -41,6 +41,7 @@
<script type="text/javascript" charset="utf-8" src="functions.js?<?php echo $dt_add ?>"></script>
<script type="text/javascript" charset="utf-8" src="feedlist.js?<?php echo $dt_add ?>"></script>
<script type="text/javascript" charset="utf-8" src="viewfeed.js?<?php echo $dt_add ?>"></script>
<script type="text/javascript" charset="utf-8" src="errors.php?mode=js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>