Prechádzať zdrojové kódy

Fix .htaccess, better error page rendering

Nathaniel van Diepen 8 rokov pred
rodič
commit
7baefccad5
3 zmenil súbory, kde vykonal 53 pridanie a 5 odobranie
  1. 4 4
      .htaccess
  2. 19 0
      js/error.js
  3. 30 1
      templates/error.php

+ 4 - 4
.htaccess

@@ -3,10 +3,10 @@ DirectoryIndex index.php
 <IfModule mod_rewrite.c>
 	RewriteEngine On
 	RewriteBase /bugs/
-	RewriteCond %{REQUEST_FILENAME} !-d
-	RewriteCond %{REQUEST_FILENAME} !-f
-	RewriteCond %{ENV:REDIRECT_STATUS} ^.
-	RewriteRule .* - [L]
+	RewriteCond %{REQUEST_FILENAME} -s [OR]
+	RewriteCond %{REQUEST_FILENAME} -l [OR]
+	RewriteCond %{REQUEST_FILENAME} -d
+	RewriteRule ^.*$ - [NC,L]
 	RewriteRule ^(?!(index\.php)|(login\.php)) index.php
 </IfModule>
 # File security

+ 19 - 0
js/error.js

@@ -0,0 +1,19 @@
+ready(function(){
+	dom.get('body>div')
+		.css({
+			margin: 0,
+			padding: '5px'
+		})
+		.each(function(i){
+			if(i%2 == 1){
+				dom.get(this)
+					.css({
+						backgroundColor: 'lightgray'
+					});
+			}
+		});
+	dom.get('body>div ul')
+		.css({
+			margin: 0
+		});
+});

+ 30 - 1
templates/error.php

@@ -5,11 +5,40 @@
 	<head>
 		<meta charset="utf8"/>
 		<title>Error</title>
+		<script src="js/juju/core.js"></script>
+		<script src="js/juju/page.js"></script>
+		<script src="js/juju/dom.js"></script>
+		<script src="js/juju/keyboard.js"></script>
+		<script src="js/juju/mouse.js"></script>
+		<script src="js/error.js"></script>
 	</head>
 	<body>
 		<h2>
 			<?=$context->error['message']?>
 		</h2>
-		<pre><?=print_r($context->backtrace,true)?></pre>
+		<?php
+			foreach($context->backtrace as $trace){
+				echo "<div>";
+				if(isset($trace['file'])){
+					echo "<div>Location: {$trace['file']}:{$trace['line']}</div>";
+				}
+				if(isset($trace['class'])){
+					echo "<div>Function: {$trace['class']}{$trace['type']}{$trace['function']}</div>";
+				}elseif(isset($trace['function'])){
+					echo "<div>Function: {$trace['function']}</div>";
+				}
+				if(isset($trace['args'])){
+					echo "<div>Arguments:<ul>";
+					foreach($trace['args'] as $arg){
+						echo "<li><pre>".json_encode($arg,JSON_PRETTY_PRINT)."</pre></li>";
+					}
+					echo "</ul></div>";
+				}
+				if(isset($trace['object'])){
+					echo "<div>Object:<pre>".json_encode($trace['object'],JSON_PRETTY_PRINT)."</pre></div>";
+				}
+				echo "</div>";
+			}
+		?>
 	</body>
 </html>