Fix the site!
This commit is contained in:
parent
dbabeeefb9
commit
40a7e25ffe
|
@ -14,4 +14,4 @@ $config = array(
|
||||||
|
|
||||||
ini_set("error_reporting", "true");
|
ini_set("error_reporting", "true");
|
||||||
|
|
||||||
error_reporting(E_ALL | E_STRCT);
|
error_reporting(E_ALL | E_STRICT);
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
function console_log( $data ) {
|
function console_log( $data ) {
|
||||||
echo "<script>";
|
echo "<script>";
|
||||||
echo "console.log(". json_encode( $data ) . ")";
|
echo "console.log(". json_encode( $data ) . ")";
|
||||||
echo "</script";
|
echo "</script>";
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* List the subdirectories of a folder.
|
* List the subdirectories of a folder.
|
||||||
|
@ -107,7 +107,6 @@ function tidyName( $name ) {
|
||||||
function isPathValid( $file, $path ) {
|
function isPathValid( $file, $path ) {
|
||||||
$realFile = realpath( $file );
|
$realFile = realpath( $file );
|
||||||
$realDir = realpath( $path );
|
$realDir = realpath( $path );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the two paths match, then the path is valid
|
* If the two paths match, then the path is valid
|
||||||
*/
|
*/
|
||||||
|
@ -143,14 +142,17 @@ function sendFile( $image ) {
|
||||||
|
|
||||||
//$etag = md5_file( $image );
|
//$etag = md5_file( $image );
|
||||||
|
|
||||||
|
ob_clean();
|
||||||
header("Last-Modified: $lastModified GMT");
|
header("Last-Modified: $lastModified GMT");
|
||||||
header("Pragma: public");
|
header("Pragma: public");
|
||||||
header("Cache-Control: max-age=$expires");
|
header("Cache-Control: max-age=$expires");
|
||||||
//header("Etag: $etag");
|
//header("Etag: $etag");
|
||||||
header("Expires: " . gmdate('D, d M Y H:i:s', time() + $expires) . " GMT");
|
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!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
15
index.php
15
index.php
|
@ -16,7 +16,7 @@ require_once("backend/config.php");
|
||||||
|
|
||||||
require_once("backend/functions.php");
|
require_once("backend/functions.php");
|
||||||
|
|
||||||
|
$error = "";
|
||||||
$imagesFolder = $config["images"];
|
$imagesFolder = $config["images"];
|
||||||
|
|
||||||
|
|
||||||
|
@ -56,9 +56,11 @@ if ( isset( $_GET["image"] ) ) {
|
||||||
$image = relativeToAbsolute( stripslashes( $_GET["image"] ), $imagesFolder );
|
$image = relativeToAbsolute( stripslashes( $_GET["image"] ), $imagesFolder );
|
||||||
|
|
||||||
if ( isPathValid( $image, $imagesFolder ) ) {
|
if ( isPathValid( $image, $imagesFolder ) ) {
|
||||||
|
console_log("Found valid image at " . $imagesFolder . $image);
|
||||||
return sendFile($image);
|
return sendFile($image);
|
||||||
} else {
|
} else {
|
||||||
$error = "Image not found";
|
$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.
|
* 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 = 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 ) ) {
|
if ( !file_exists( $thumb ) ) {
|
||||||
createThumbnail( $image, $thumb, $config["thumbs"] );
|
createThumbnail( $image, $thumb, $config["thumbs"] );
|
||||||
}
|
}
|
||||||
|
@ -99,6 +103,7 @@ if ( isset( $_GET["thumb"] ) ) {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$error = "Image not found!";
|
$error = "Image not found!";
|
||||||
|
console_log($error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +121,7 @@ if ( isset( $_GET["category"] ) ) {
|
||||||
|
|
||||||
if ( isPathValid( $tempDir, $imagesFolder ) ) {
|
if ( isPathValid( $tempDir, $imagesFolder ) ) {
|
||||||
console_log("Directory is valid.");
|
console_log("Directory is valid.");
|
||||||
$dir = $tempDir;
|
$imagesFolder = $tempDir;
|
||||||
} else {
|
} else {
|
||||||
console_log("Directory is invalid");
|
console_log("Directory is invalid");
|
||||||
$error = "Invalid category";
|
$error = "Invalid category";
|
||||||
|
|
|
@ -11,12 +11,16 @@ $("document").ready(function() {
|
||||||
$("#loading").show();
|
$("#loading").show();
|
||||||
title = encodeURI($(this).children(".title").children("a").attr("href"));
|
title = encodeURI($(this).children(".title").children("a").attr("href"));
|
||||||
Name = $(this).children(".title").children("a").html();
|
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);
|
updateURL(title, Name);
|
||||||
});
|
});
|
||||||
|
|
||||||
$(".thumb").click(function() {
|
$(".thumb").click(function() {
|
||||||
title = encodeURI($(this).children("a").attr("bref"));
|
title = encodeURI($(this).children("a").attr("href"));
|
||||||
$("#lightbox").html('<img src="' + title + '">');
|
$("#lightbox").html('<img src="' + title + '">');
|
||||||
$("#viewer").fadeIn();
|
$("#viewer").fadeIn();
|
||||||
return false;
|
return false;
|
||||||
|
@ -25,4 +29,6 @@ $("document").ready(function() {
|
||||||
$("#container").click(function() {
|
$("#container").click(function() {
|
||||||
$("#viewer").fadeOut();
|
$("#viewer").fadeOut();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$(".loading").hide();
|
||||||
});
|
});
|
|
@ -56,13 +56,16 @@ if( count( $pictures ) > 0 ) { ?>
|
||||||
<div id="thumbs">
|
<div id="thumbs">
|
||||||
<?php
|
<?php
|
||||||
foreach ($pictures as $file ) {
|
foreach ($pictures as $file ) {
|
||||||
$picture = absoluteToRelative( $file, $imagesFolder);
|
$picture = absoluteToRelative( $file, $config["images"]);
|
||||||
$name = tidyName( $file );
|
$picture = str_replace("\\", "/", $picture);
|
||||||
|
console_log($picture);
|
||||||
|
|
||||||
|
//$name = tidyName( $file );
|
||||||
|
|
||||||
$createFile = "";
|
$createFile = "";
|
||||||
|
|
||||||
foreach( $new as $entry ) {
|
foreach( $newImages as $entry ) {
|
||||||
$path = getPath( $file );
|
$path = realPath( $file );
|
||||||
|
|
||||||
if( isInFolder( $path, $entry ) ) {
|
if( isInFolder( $path, $entry ) ) {
|
||||||
$createFile = "new";
|
$createFile = "new";
|
||||||
|
@ -86,5 +89,5 @@ if( count( $pictures ) > 0 ) { ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div id="loading">
|
</div id="loading">
|
||||||
Loading.
|
<?php echo $error ?>
|
||||||
</div>
|
</div>
|
Loading…
Reference in New Issue
Block a user