Fix the site!

This commit is contained in:
Curle 2020-10-08 07:04:46 +01:00
parent dbabeeefb9
commit 40a7e25ffe
Signed by: TheCurle
GPG Key ID: 2F2E62F0DA69A5AE
5 changed files with 34 additions and 18 deletions

View File

@ -14,4 +14,4 @@ $config = array(
ini_set("error_reporting", "true");
error_reporting(E_ALL | E_STRCT);
error_reporting(E_ALL | E_STRICT);

View File

@ -7,7 +7,7 @@
function console_log( $data ) {
echo "<script>";
echo "console.log(". json_encode( $data ) . ")";
echo "</script";
echo "</script>";
}
/**
* List the subdirectories of a folder.
@ -107,7 +107,6 @@ function tidyName( $name ) {
function isPathValid( $file, $path ) {
$realFile = realpath( $file );
$realDir = realpath( $path );
/**
* If the two paths match, then the path is valid
*/
@ -143,14 +142,17 @@ function sendFile( $image ) {
//$etag = md5_file( $image );
ob_clean();
header("Last-Modified: $lastModified GMT");
header("Pragma: public");
header("Cache-Control: max-age=$expires");
//header("Etag: $etag");
header("Expires: " . gmdate('D, d M Y H:i:s', time() + $expires) . " GMT");
header("Content-type: image/jpeg");
header("Content-type: image/png");
readfile( $image );
if(!readfile( $image )) {
console_log("Problem with file $image!");
}
}
/**

View File

@ -16,7 +16,7 @@ require_once("backend/config.php");
require_once("backend/functions.php");
$error = "";
$imagesFolder = $config["images"];
@ -56,9 +56,11 @@ if ( isset( $_GET["image"] ) ) {
$image = relativeToAbsolute( stripslashes( $_GET["image"] ), $imagesFolder );
if ( isPathValid( $image, $imagesFolder ) ) {
console_log("Found valid image at " . $imagesFolder . $image);
return sendFile($image);
} else {
$error = "Image not found";
console_log($error);
}
}
@ -81,11 +83,13 @@ if ( isset( $_GET["thumb"] ) ) {
* We can only spend so much time processing a tiny image, after all.
*/
$image = relativeToAbsolute( stripslashes( $_GET["thumb"] ), $imagesFolder );
$image = relativeToAbsolute( stripslashes( $_GET["thumb"] ), $config["images"]);
$image = str_replace("\/", "//", $image);
$thumb = relativeToAbsolute( stripslashes( $_GET["thumb"] ), $config["thumbs"]);
$thumb = str_replace("\/", "//", $thumb);
if ( isPathValid( $image, $imagesFolder ) ) {
if ( isPathValid( $image, $config["images"] ) ) {
console_log("Image is valid");
if ( !file_exists( $thumb ) ) {
createThumbnail( $image, $thumb, $config["thumbs"] );
}
@ -99,6 +103,7 @@ if ( isset( $_GET["thumb"] ) ) {
} else {
$error = "Image not found!";
console_log($error);
}
}
@ -116,7 +121,7 @@ if ( isset( $_GET["category"] ) ) {
if ( isPathValid( $tempDir, $imagesFolder ) ) {
console_log("Directory is valid.");
$dir = $tempDir;
$imagesFolder = $tempDir;
} else {
console_log("Directory is invalid");
$error = "Invalid category";

View File

@ -11,12 +11,16 @@ $("document").ready(function() {
$("#loading").show();
title = encodeURI($(this).children(".title").children("a").attr("href"));
Name = $(this).children(".title").children("a").html();
$("body").load(title);
$("body").load(title, function( response, status, xhr ) {
if ( status == "error" ) {
var msg = "Sorry but there was an error: ";
$( "#error" ).html( msg + xhr.status + " " + xhr.statusText );
}});
updateURL(title, Name);
});
$(".thumb").click(function() {
title = encodeURI($(this).children("a").attr("bref"));
title = encodeURI($(this).children("a").attr("href"));
$("#lightbox").html('<img src="' + title + '">');
$("#viewer").fadeIn();
return false;
@ -25,4 +29,6 @@ $("document").ready(function() {
$("#container").click(function() {
$("#viewer").fadeOut();
});
$(".loading").hide();
});

View File

@ -56,13 +56,16 @@ if( count( $pictures ) > 0 ) { ?>
<div id="thumbs">
<?php
foreach ($pictures as $file ) {
$picture = absoluteToRelative( $file, $imagesFolder);
$name = tidyName( $file );
$picture = absoluteToRelative( $file, $config["images"]);
$picture = str_replace("\\", "/", $picture);
console_log($picture);
//$name = tidyName( $file );
$createFile = "";
foreach( $new as $entry ) {
$path = getPath( $file );
foreach( $newImages as $entry ) {
$path = realPath( $file );
if( isInFolder( $path, $entry ) ) {
$createFile = "new";
@ -86,5 +89,5 @@ if( count( $pictures ) > 0 ) { ?>
</div>
</div id="loading">
Loading.
<?php echo $error ?>
</div>