Added proper 404 errors on file or directory not found
[bizou.git] / view.php
index 551af85..1f98767 100644 (file)
--- a/view.php
+++ b/view.php
@@ -24,6 +24,11 @@ if ($shortPath == '/') $shortPath = '';
 // extra security check to avoid /photos/index/../.. like urls, maybe useless but..
 if (strpos($shortPath, '..') !== false) die(".. found in url");
 
+if (! is_file(IMAGES_DIR.$shortPath)) {
+       header("HTTP/1.1 404 Not Found");
+       die("File Not Found");
+}
+
 $scriptPath = $_SERVER["SCRIPT_NAME"];
 
 // get all images in an array
@@ -112,8 +117,21 @@ img {
 </style>
 
 <?php if ($nextImageUrl !== '') { ?>
+ <?php if (strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') !== false) { ?>
 <link rel="prefetch" href="<?php echo $nextImageUrl ?>" />
 <link rel="prefetch" href="<?php echo $nextPageUrl ?>" />
+
+ <?php } else { ?>
+<script type="text/javascript">
+window.onload = function() {
+       var im = new Image();
+       im.src = '<?php echo $nextImageUrl ?>';
+       var req = new XMLHttpRequest();
+       req.open('GET', '<?php echo $nextPageUrl ?>', false);
+       req.send(null);
+};
+</script>
+ <?php } ?>
 <?php } ?>
 
 </head>