summaryrefslogtreecommitdiff
path: root/modules/gallery/views/kohana_error_page.php
blob: 0d8801e503ff76fd164b35cdbe0bbaaee49a1883 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<?php defined("SYSPATH") or die("No direct script access.") ?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <style type="text/css">
      body {
        background: #fff;
        font-size: 14px;
        line-height: 130%;
      }

      div.big_box {
        padding: 10px;
        background: #eee;
        border: solid 1px #ccc;
        font-family: sans-serif;
        color: #111;
        width: 42em;
        margin: 20px auto;
      }

      div#framework_error {
        text-align: center;
      }

      div#error_details {
        text-align: left;
      }

      code {
        font-family: monospace;
        font-size: 12px;
        margin: 20px;
        color: #333;
        white-space: pre-wrap;
        white-space: -moz-pre-wrap;
        word-wrap: break-word;
      }

      h3 {
        font-family: sans-serif;
        margin: 2px 0px 0px 0px;
        padding: 8px 0px 0px 0px;
        border-top: 1px solid #ddd;
      }

      p {
        padding: 0px;
        margin: 0px 0px 10px 0px;
      }

      li, pre {
        padding: 0px;
        margin: 0px;
      }
    </style>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title><?= t("Something went wrong!") ?></title>
  </head>
  <body>
    <? try { $user = identity::active_user(); } catch (Exception $e) { } ?>
    <? $admin = php_sapi_name() == "cli" || isset($user) && $user->admin ?>
    <div class="big_box" id="framework_error">
      <h1>
        <?= t("Dang...  Something went wrong!") ?>
      </h1>
      <h2>
        <?= t("We tried really hard, but it's broken.") ?>
      </h2>
      <? if (!$admin): ?>
      <p>
        <?= t("Talk to your Gallery administrator for help fixing this!") ?>
      </p>
      <? endif ?>
    </div>
    <? if ($admin): ?>
    <div class="big_box" id="error_details">
      <h2>
        <?= t("Hey wait, you're an admin!  We can tell you stuff.") ?>
      </h2>
      <script type="text/javascript">
        var show_details = function() {
          document.getElementById("stuff").style.display = "block";
          document.getElementById("toggle").style.display = "none";
        }
      </script>
      <a id="toggle" href="#" onclick="javascript:show_details(); return false;">
        <b><?= t("Ok.. tell me stuff!") ?></b>
      </a>
      <div id="stuff" style="display: none">
        <? if (!empty($line) and !empty($file)): ?>
        <div id="summary">
          <h3>
            <?= t("Help!") ?>
          </h3>
          <p>
            <?= t("If this stuff doesn't make any sense to you, <a href=\"%url\">ask for help in the Gallery forums</a>!", array("url" => "http://gallery.menalto.com/forum/96")) ?>
          </p>
          <h3>
            <?= t("So here's the error:") ?>
          </h3>

          <code class="block"><?= $message ?></code>
          <p>
            <?= t("File: <b>%file</b>, line: <b>%line</b>", array("file" => $file, "line" => $line)) ?>
          </p>
        </div>
        <? endif ?>

        <? $trace = $PHP_ERROR ? array_slice(debug_backtrace(), 1) : $exception->getTrace(); ?>
        <? $trace = Kohana::backtrace($trace); ?>
        <? if (!empty($trace)): ?>
        <div id="stack_trace">
          <h3>
            <?= t("And here's how we got there:") ?>
          </h3>
          <?= $trace ?>
          <? endif ?>
        </div>
      </div>
      <? else: ?>
      <? $trace = $PHP_ERROR ? array_slice(debug_backtrace(), 1) : $exception->getTraceAsString(); ?>
      <? if (!empty($trace)): ?>
      <? Kohana::Log("error", print_r($trace, 1)); ?>
      <? endif ?>
      <? endif ?>
  </body>
</html>